Search in sources :

Example 26 with IGenerationResult

use of org.eclipse.vorto.plugin.generator.IGenerationResult 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 27 with IGenerationResult

use of org.eclipse.vorto.plugin.generator.IGenerationResult 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)

Example 28 with IGenerationResult

use of org.eclipse.vorto.plugin.generator.IGenerationResult in project vorto by eclipse.

the class EclipseHonoArduinoGeneratorTest method testAPIFunctionBlockWithOperations.

/*
   * Test case for checking whether the operations specified in the functionblock is not reflected
   * in the generated files. This is because we currently do not support events.
   * 
   */
@Test
public void testAPIFunctionBlockWithOperations() 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("testOperation"));
}
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 29 with IGenerationResult

use of org.eclipse.vorto.plugin.generator.IGenerationResult in project vorto by eclipse.

the class EclipseHonoJavaGeneratorTest method checkAPIEmptyNamespaceInfomodelHono.

/*
   * Test case for checking infomodel with empty namespace
   */
// Issue created https://github.com/eclipse/vorto/issues/1885
@Ignore
@Test(expected = ParsingException.class)
public void checkAPIEmptyNamespaceInfomodelHono() throws Exception {
    InformationModel emptyNameSpaceInfomodel = BuilderUtils.newInformationModel(new ModelId(org.eclipse.vorto.core.api.model.model.ModelType.InformationModel, "emptyNameSpaceInfomodel", "", "1.0.0")).build();
    IGenerationResult generationResult = eclipseHonoJavaGenerator.generate(emptyNameSpaceInfomodel, InvocationContext.simpleInvocationContext());
}
Also used : InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) IGenerationResult(org.eclipse.vorto.plugin.generator.IGenerationResult) ModelId(org.eclipse.vorto.core.api.model.model.ModelId) Ignore(org.junit.Ignore) AbstractGeneratorTest(org.eclipse.vorto.plugin.AbstractGeneratorTest) Test(org.junit.Test)

Example 30 with IGenerationResult

use of org.eclipse.vorto.plugin.generator.IGenerationResult in project vorto by eclipse.

the class EclipseHonoJavaGeneratorTest method testAPIFunctionBlockWithOperations.

/*
   * Test case for checking whether the operations specified in the functionblock is not reflected
   * in the generated files. This is because we currently do not support events.
   * 
   */
@Test
public void testAPIFunctionBlockWithOperations() throws Exception {
    IGenerationResult generationResult = eclipseHonoJavaGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedfile = zipFileReader(generationResult, "eventsAndOperationsFunctionBlock", ".java");
    assertEquals(false, new String(generatedfile.getContent(), "utf-8").contains("testOperation"));
}
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)

Aggregations

IGenerationResult (org.eclipse.vorto.plugin.generator.IGenerationResult)34 Test (org.junit.Test)33 AbstractGeneratorTest (org.eclipse.vorto.plugin.AbstractGeneratorTest)32 Generated (org.eclipse.vorto.plugin.generator.utils.Generated)27 File (java.io.File)17 HashMap (java.util.HashMap)7 InvocationContext (org.eclipse.vorto.plugin.generator.InvocationContext)4 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)3 ModelId (org.eclipse.vorto.core.api.model.model.ModelId)3 HashSet (java.util.HashSet)2 FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)2 Context (com.amazonaws.services.lambda.runtime.Context)1 RequestStreamHandler (com.amazonaws.services.lambda.runtime.RequestStreamHandler)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Optional (java.util.Optional)1