Search in sources :

Example 16 with IGenerationResult

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

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

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

Example 19 with IGenerationResult

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

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

the class EclipseDittoGeneratorTest method checkThingStructure.

@Test
public void checkThingStructure() throws Exception {
    Map<String, String> config = new HashMap<>();
    config.put("target", "thingJson");
    IGenerationResult generationResult = eclipseDittoGenerator.generate(modelProvider("MultiplTypeIm.infomodel", "MultipleTypeFb.functionblock"), InvocationContext.simpleInvocationContext(config));
    assertEquals("application/json", generationResult.getMediatype());
}
Also used : HashMap(java.util.HashMap) 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