Search in sources :

Example 16 with Generated

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

the class EclipseHonoArduinoGeneratorTest method testClientAppGeneratedModels.

/*
   * -----Below test cases are specific to Client App related files-------
   */
/*
   * Test case for checking whether the client App generated contains the models which are listed in
   * the information model
   * 
   */
@Test
public void testClientAppGeneratedModels() throws GeneratorException, IOException, URISyntaxException {
    IGenerationResult generationResult = eclipseArduinoGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedfile = zipFileReader(generationResult, "MySensor.cpp", ".cpp");
    File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/MySensor.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)

Example 17 with Generated

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

the class EclipseDittoGeneratorTest method checkAPIConfigPropertiesInFunctionBlock.

/*
   * Test case for checking whether the config properties are reflected in json
   */
@Test
public void checkAPIConfigPropertiesInFunctionBlock() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("target", "jsonSchema");
    IGenerationResult generationResult = eclipseDittoGenerator.generate(modelProvider("MultiplTypeIm.infomodel", "MultipleTypeFb.functionblock"), InvocationContext.simpleInvocationContext(params));
    Generated generatedfile = zipFileReader(generationResult, "properties-configuration.schema", ".json");
    File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/properties-configuration.schema.json").toURI());
    assertEquals(IOUtils.toString(FileUtils.openInputStream(defaultFile)), new String(generatedfile.getContent(), "utf-8"));
}
Also used : Generated(org.eclipse.vorto.plugin.generator.utils.Generated) HashMap(java.util.HashMap) IGenerationResult(org.eclipse.vorto.plugin.generator.IGenerationResult) File(java.io.File) AbstractGeneratorTest(org.eclipse.vorto.plugin.AbstractGeneratorTest) Test(org.junit.Test)

Example 18 with Generated

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

the class EclipseDittoGeneratorTest method checkMultipleKeywordInFunctionBlock.

/*
   * Test case for checking whether the multiple keyword generates corresponding array type in json
   *
   */
@Test
public void checkMultipleKeywordInFunctionBlock() throws Exception {
    Map<String, String> params = new HashMap<>();
    params.put("target", "jsonSchema");
    IGenerationResult generationResult = eclipseDittoGenerator.generate(modelProvider("MultiplTypeIm.infomodel", "MultipleTypeFb.functionblock"), InvocationContext.simpleInvocationContext(params));
    Generated generatedfile = zipFileReader(generationResult, "properties-status.schema", ".json");
    File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/properties-status.schema.json").toURI());
    assertEquals(IOUtils.toString(FileUtils.openInputStream(defaultFile)), new String(generatedfile.getContent(), "utf-8"));
}
Also used : Generated(org.eclipse.vorto.plugin.generator.utils.Generated) HashMap(java.util.HashMap) IGenerationResult(org.eclipse.vorto.plugin.generator.IGenerationResult) File(java.io.File) AbstractGeneratorTest(org.eclipse.vorto.plugin.AbstractGeneratorTest) Test(org.junit.Test)

Example 19 with Generated

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

the class BoschIoTSuiteGeneratorTest method generatePython.

/*
   * Check if python file is generated when language is passed as python to BoschIOTSuiteGenerator
   */
@Test
public void generatePython() throws Exception {
    configProperties.put("language", "python");
    InvocationContext context = new InvocationContext(mappingModels, configProperties);
    IGenerationResult iGenerationResult = boschIOTSuiteGenerator.generate(modelProvider(), context);
    Generated generatedfile = zipFileReader(iGenerationResult, "StatusPropertiesFunctionBlock", ".py");
    assertEquals("StatusPropertiesFunctionBlock.py", 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 20 with Generated

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

the class EclipseHonoArduinoGeneratorTest method checkAPIConfigPropertiesInFunctionBlock.

/*
   * Test case for checking whether the functionblock related file has the config properties both
   * primitive and object with the setters and getters
   * 
   */
@Test
public void checkAPIConfigPropertiesInFunctionBlock() throws Exception {
    IGenerationResult generationResult = eclipseArduinoGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedfile = zipFileReader(generationResult, "ConfigPropertiesFunctionBlock.cpp", ".cpp");
    File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/ConfigPropertiesFunctionBlock.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