Search in sources :

Example 11 with Generated

use of org.eclipse.vorto.plugin.generator.utils.Generated in project vorto by eclipse.

the class BoschIoTSuiteGeneratorTest method generateArduino.

/*
   * Check if cpp file is generated when language is passed as arduino to BoschIOTSuiteGenerator
   */
@Test
public void generateArduino() throws Exception {
    configProperties.put("language", "arduino");
    InvocationContext context = new InvocationContext(mappingModels, configProperties);
    IGenerationResult iGenerationResult = boschIOTSuiteGenerator.generate(modelProvider(), context);
    Generated generatedfile = zipFileReader(iGenerationResult, "StatusPropertiesFunctionBlock", ".cpp");
    assertEquals("StatusPropertiesFunctionBlock.cpp", generatedfile.getFileName());
}
Also used : Generated(org.eclipse.vorto.plugin.generator.utils.Generated) InvocationContext(org.eclipse.vorto.plugin.generator.InvocationContext) IGenerationResult(org.eclipse.vorto.plugin.generator.IGenerationResult) AbstractGeneratorTest(org.eclipse.vorto.plugin.AbstractGeneratorTest) Test(org.junit.Test)

Example 12 with Generated

use of org.eclipse.vorto.plugin.generator.utils.Generated in project vorto by eclipse.

the class BoschIoTSuiteGeneratorTest method generateJava.

/*
   * Check if java file is generated when language is passed as java to BoschIOTSuiteGenerator
   */
@Test
public void generateJava() throws Exception {
    configProperties.put("language", "python");
    InvocationContext context = new InvocationContext(mappingModels, configProperties);
    IGenerationResult iGenerationResult = boschIOTSuiteGenerator.generate(modelProvider(), context);
    Generated generatedfile = zipFileReader(iGenerationResult, "StatusPropertiesFunctionBlock", ".java");
    assertEquals("StatusPropertiesFunctionBlock.java", generatedfile.getFileName());
}
Also used : Generated(org.eclipse.vorto.plugin.generator.utils.Generated) InvocationContext(org.eclipse.vorto.plugin.generator.InvocationContext) IGenerationResult(org.eclipse.vorto.plugin.generator.IGenerationResult) AbstractGeneratorTest(org.eclipse.vorto.plugin.AbstractGeneratorTest) Test(org.junit.Test)

Example 13 with Generated

use of org.eclipse.vorto.plugin.generator.utils.Generated in project vorto by eclipse.

the class EclipseHonoArduinoGeneratorTest method testConnectorGeneratedMQTTClient.

/*
   * -----Below test cases are specific to Connector related files-------
   */
/*
   * Test case for checking whether the MQTT client generated contains the models which are listed
   * in the information model
   * 
   */
@Test
public void testConnectorGeneratedMQTTClient() throws GeneratorException, IOException, URISyntaxException {
    IGenerationResult generationResult = eclipseArduinoGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedFile = zipFileReader(generationResult, "MySensorApp.ino", ".ino");
    File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/MySensorApp.ino").toURI());
    assertEquals(TestUtils.normalizeEOL(IOUtils.toString(FileUtils.openInputStream(defaultFile))), TestUtils.normalizeEOL(new String(generatedFile.getContent(), "utf-8")));
}
Also used : Generated(org.eclipse.vorto.plugin.generator.utils.Generated) IGenerationResult(org.eclipse.vorto.plugin.generator.IGenerationResult) File(java.io.File) AbstractGeneratorTest(org.eclipse.vorto.plugin.AbstractGeneratorTest) Test(org.junit.Test)

Example 14 with Generated

use of org.eclipse.vorto.plugin.generator.utils.Generated in project vorto by eclipse.

the class EclipseHonoArduinoGeneratorTest method testAPIFunctionBlockWithEvents.

/*
   * Test case for checking whether the events specified in the functionblock is not reflected in
   * the generated files. This is because we currently do not support events.
   * 
   */
@Test
public void testAPIFunctionBlockWithEvents() throws Exception {
    IGenerationResult generationResult = eclipseArduinoGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedfile = zipFileReader(generationResult, "eventsAndOperationsFunctionBlock.cpp", ".cpp");
    assertEquals(false, new String(generatedfile.getContent(), "utf-8").contains("testEvent"));
}
Also used : Generated(org.eclipse.vorto.plugin.generator.utils.Generated) IGenerationResult(org.eclipse.vorto.plugin.generator.IGenerationResult) AbstractGeneratorTest(org.eclipse.vorto.plugin.AbstractGeneratorTest) Test(org.junit.Test)

Example 15 with Generated

use of org.eclipse.vorto.plugin.generator.utils.Generated in project vorto by eclipse.

the class EclipseHonoArduinoGeneratorTest method checkAPIGenerationOfEntityModel.

/*
   * Test case for checking whether the datatype related file has the entity and enum values
   * specified in the input datatype file.
   * 
   */
@Test
public void checkAPIGenerationOfEntityModel() throws Exception {
    IGenerationResult generationResult = eclipseArduinoGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedfile = zipFileReader(generationResult, "UnitEntity.cpp", ".cpp");
    File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/UnitEntity.cpp").toURI());
    assertEquals(TestUtils.normalizeEOL(IOUtils.toString(FileUtils.openInputStream(defaultFile))), TestUtils.normalizeEOL(new String(generatedfile.getContent(), "utf-8")));
}
Also used : Generated(org.eclipse.vorto.plugin.generator.utils.Generated) IGenerationResult(org.eclipse.vorto.plugin.generator.IGenerationResult) File(java.io.File) AbstractGeneratorTest(org.eclipse.vorto.plugin.AbstractGeneratorTest) Test(org.junit.Test)

Aggregations

Generated (org.eclipse.vorto.plugin.generator.utils.Generated)27 AbstractGeneratorTest (org.eclipse.vorto.plugin.AbstractGeneratorTest)26 IGenerationResult (org.eclipse.vorto.plugin.generator.IGenerationResult)26 Test (org.junit.Test)26 File (java.io.File)16 InvocationContext (org.eclipse.vorto.plugin.generator.InvocationContext)3 HashMap (java.util.HashMap)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1