test_class.file: vorto-importers/lwm2m/lwm2m-importer/src/test/java/org/eclipse/vorto/plugins/importer/example/lwm2m/LwM2MImporterTest.java
test_class.identifier: LwM2MImporterTest
test_case.body: @Test
    public void testConversion()throws Exception {
      final String filename = "3328_1_1.xml";
      
      InputStream lwm2mXml = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);    
      
      LwM2MImporter importer = new LwM2MImporter();
      
      byte[] convertedContent = importer.convert(lwm2mXml);
      
      ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(convertedContent));
      ZipEntry entry = null;
      
      Map<String,byte[]> content = new HashMap<>();
      while ((entry = zis.getNextEntry()) != null) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        IOUtils.copy(zis, baos);
        content.put(entry.getName(),baos.toByteArray());
      }
      
      assertEquals(2,content.keySet().size());
      assertTrue(content.keySet().contains("Power.fbmodel"));
      assertTrue(content.keySet().contains("Power.mapping"));
      
      System.out.println(new String(content.get("Power.fbmodel")));
      System.out.println(new String(content.get("Power.mapping")));
    }
test_case.class_method_signature: LwM2MImporterTest.testConversion()
test_case.full_signature: @Test public void testConversion()
test_case.identifier: testConversion
test_case.invocations: getResourceAsStream getContextClassLoader currentThread convert getNextEntry copy put getName toByteArray assertEquals size keySet assertTrue contains keySet assertTrue contains keySet println get println get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testConversion()
focal_class.declarator: NAMESPACE = "com.ipso.smartobjects"
focal_class.modifier: private static final
focal_class.original_string: private static final String NAMESPACE = "com.ipso.smartobjects";
focal_class.type: String
focal_class.var_name: NAMESPACE
focal_class.declarator: VERSION = "1.1.0"
focal_class.modifier: private static final
focal_class.original_string: private static final String VERSION = "1.1.0";
focal_class.type: String
focal_class.var_name: VERSION
focal_class.declarator: FB_TEMPLATE = new FunctionblockTemplate()
focal_class.modifier: private static final
focal_class.original_string: private static final FunctionblockTemplate FB_TEMPLATE = new FunctionblockTemplate();
focal_class.type: FunctionblockTemplate
focal_class.var_name: FB_TEMPLATE
focal_class.declarator: MAPPING_TEMPLATE = new MappingTemplate()
focal_class.modifier: private static final
focal_class.original_string: private static final MappingTemplate MAPPING_TEMPLATE = new MappingTemplate();
focal_class.type: MappingTemplate
focal_class.var_name: MAPPING_TEMPLATE
focal_class.file: vorto-importers/lwm2m/lwm2m-importer/src/main/java/org/eclipse/vorto/plugins/importer/example/lwm2m/LwM2MImporter.java
focal_class.identifier: LwM2MImporter
focal_class.class_method_signature: LwM2MImporter.validate(InputStream fileInput)
focal_class.full_signature: public ValidationReport validate(InputStream fileInput)
focal_class.identifier: validate
focal_class.modifiers: public
focal_class.parameters: (InputStream fileInput)
focal_class.return: ValidationReport
focal_class.signature: ValidationReport validate(InputStream fileInput)
focal_class.class_method_signature: LwM2MImporter.parse(InputStream fileInput)
focal_class.full_signature: private LWM2M parse(InputStream fileInput)
focal_class.identifier: parse
focal_class.modifiers: private
focal_class.parameters: (InputStream fileInput)
focal_class.return: LWM2M
focal_class.signature: LWM2M parse(InputStream fileInput)
focal_class.class_method_signature: LwM2MImporter.convert(InputStream fileInput)
focal_class.full_signature: public byte[] convert(InputStream fileInput)
focal_class.identifier: convert
focal_class.modifiers: public
focal_class.parameters: (InputStream fileInput)
focal_class.return: byte[]
focal_class.signature: byte[] convert(InputStream fileInput)
focal_class.class_method_signature: LwM2MImporter.createModelId(Object obj)
focal_class.full_signature: private ModelId createModelId(Object obj)
focal_class.identifier: createModelId
focal_class.modifiers: private
focal_class.parameters: (Object obj)
focal_class.return: ModelId
focal_class.signature: ModelId createModelId(Object obj)
focal_class.class_method_signature: LwM2MImporter.parseId(String name)
focal_class.full_signature: private String parseId(String name)
focal_class.identifier: parseId
focal_class.modifiers: private
focal_class.parameters: (String name)
focal_class.return: String
focal_class.signature: String parseId(String name)
focal_method.body: public byte[] convert(InputStream fileInput) {
  		ByteArrayOutputStream baos = new ByteArrayOutputStream();
  		ZipOutputStream zip = new ZipOutputStream(baos);
  
  		try {
  			LWM2M lwm2m = parse(fileInput);
  
  			try {
  				for (LWM2M.Object obj : lwm2m.getObject()) {
  
  					final ModelId modelId = createModelId(obj);
  
  					ZipEntry fbEntry = new ZipEntry(modelId.getName() + ".fbmodel");
  					zip.putNextEntry(fbEntry);
  					zip.write(FB_TEMPLATE.create(obj, modelId).getBytes());
  					zip.closeEntry();
  
  					ZipEntry mappingEntry = new ZipEntry(modelId.getName() + ".mapping");
  					zip.putNextEntry(mappingEntry);
  					zip.write(MAPPING_TEMPLATE.create(obj, modelId).getBytes());
  					zip.closeEntry();
  				}
  			} catch (Exception ex) {
  				ex.printStackTrace();
  			} finally {
  				if (zip != null) {
  					zip.close();
  				}
  			}
  
  			return baos.toByteArray();
  		} catch (Exception e) {
  			throw new RuntimeException(e);
  		} finally {
  			if (baos != null) {
  				try {
  					baos.close();
  				} catch (IOException e) {
  					// TODO Auto-generated catch block
  					e.printStackTrace();
  				}
  			}
  		}
  	}
focal_method.class_method_signature: LwM2MImporter.convert(InputStream fileInput)
focal_method.full_signature: public byte[] convert(InputStream fileInput)
focal_method.identifier: convert
focal_method.invocations: parse getObject createModelId getName putNextEntry write getBytes create closeEntry getName putNextEntry write getBytes create closeEntry printStackTrace close toByteArray close printStackTrace
focal_method.modifiers: public
focal_method.parameters: (InputStream fileInput)
focal_method.return: byte[]
focal_method.signature: byte[] convert(InputStream fileInput)