Search in sources :

Example 1 with Generated

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

the class EclipseHonoJavaGeneratorTest 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 = eclipseHonoJavaGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    File defaultFileHonoDataService = new File(getClass().getClassLoader().getResource("defaultFileFormat/HonoDataService_MQTT.java").toURI());
    File defaultFileHonoMqttClient = new File(getClass().getClassLoader().getResource("defaultFileFormat/HonoMqttClient.java").toURI());
    Generated generatedFileHonoDataService = zipFileReader(generationResult, "HonoDataService", ".java");
    Generated generatedFileHonoMqttClient = zipFileReader(generationResult, "HonoMqttClient", ".java");
    // assertEquals(IOUtils.toString(FileUtils.openInputStream(defaultFileHonoDataService)),
    // new String(generatedFileHonoDataService.getContent(), "utf-8"));
    assertEquals(IOUtils.toString(FileUtils.openInputStream(defaultFileHonoMqttClient)), new String(generatedFileHonoMqttClient.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 2 with Generated

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

the class EclipseHonoJavaGeneratorTest method checkAPIGenerationOfEnumModel.

/*
   * Test case for checking whether the datatype related java file has the enum values specified in
   * the input datatype file.
   * 
   */
@Test
public void checkAPIGenerationOfEnumModel() throws Exception {
    IGenerationResult generationResult = eclipseHonoJavaGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedfile = zipFileReader(generationResult, "UnitEnum", ".java");
    File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/ValidEnum.java").toURI());
    assertEquals(IOUtils.toString(FileUtils.openInputStream(defaultFile)), 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 3 with Generated

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

the class EclipseHonoJavaGeneratorTest method checkAPIGenerationOfEntityModel.

/*
   * Test case for checking whether the datatype related java file has the entity values specified
   * in the input datatype file.
   * 
   */
@Test
public void checkAPIGenerationOfEntityModel() throws Exception {
    IGenerationResult generationResult = eclipseHonoJavaGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedfile = zipFileReader(generationResult, "UnitEntity", ".java");
    File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/ValidEntity.java").toURI());
    assertEquals(IOUtils.toString(FileUtils.openInputStream(defaultFile)), 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 4 with Generated

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

the class EclipseHonoJavaGeneratorTest 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 = eclipseHonoJavaGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedfile = zipFileReader(generationResult, "MySensorApp", ".java");
    File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/MainApp.java").toURI());
    assertEquals(IOUtils.toString(FileUtils.openInputStream(defaultFile)), 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 5 with Generated

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

the class EclipseHonoJavaGeneratorTest 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 = eclipseHonoJavaGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
    Generated generatedfile = zipFileReader(generationResult, "eventsAndOperationsFunctionBlock", ".java");
    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)

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