use of org.eclipse.vorto.plugin.generator.IGenerationResult in project vorto by eclipse.
the class EclipseHonoPythonGeneratorTest 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 = pythonGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
Generated generatedFileHonoMqttClient = zipFileReader(generationResult, "DittoSerializer", ".py");
File defaultFileHonoMqttClient = new File(getClass().getClassLoader().getResource("defaultFileFormat/DittoSerializer.py").toURI());
assertEquals(IOUtils.toString(FileUtils.openInputStream(defaultFileHonoMqttClient)), new String(generatedFileHonoMqttClient.getContent(), "utf-8"));
}
use of org.eclipse.vorto.plugin.generator.IGenerationResult in project vorto by eclipse.
the class HonoGeneratorTest method testGenerateHonoForPython.
@Test
public void testGenerateHonoForPython() throws Exception {
EclipseHonoGenerator generator = new EclipseHonoGenerator();
ModelId batteryFb = ModelIdFactory.newInstance(ModelType.InformationModel, "org.eclipse.vorto", "1.0.0", "Battery");
FunctionblockModel fbm = BuilderUtils.newFunctionblock(ModelIdFactory.newInstance(ModelType.InformationModel, "org.eclipse.vorto", "1.0.0", "Battery")).withDescription("Battery description").build();
InformationModel infomodel = BuilderUtils.newInformationModel(ModelIdFactory.newInstance(ModelType.InformationModel, "org.eclipse.vorto", "1.0.0", "MyDevice")).withFunctionBlock(fbm, "battery", "battery prop", false).withReference(batteryFb).build();
Map<String, String> properties = new HashMap<String, String>();
properties.put("language", "python");
IGenerationResult result = generator.generate(infomodel, InvocationContext.simpleInvocationContext(properties));
assertNotNull(result);
ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(result.getContent()));
ZipEntry entry = null;
Set<String> filePaths = new HashSet<>();
while ((entry = zis.getNextEntry()) != null) {
filePaths.add(entry.getName());
}
assertTrue(filePaths.contains("MyDeviceApp.py"));
}
use of org.eclipse.vorto.plugin.generator.IGenerationResult 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());
}
use of org.eclipse.vorto.plugin.generator.IGenerationResult 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());
}
use of org.eclipse.vorto.plugin.generator.IGenerationResult in project vorto by eclipse.
the class EclipseHonoArduinoGeneratorTest method checkAPIStatusPropertiesInFunctionBlock.
/*
* -----Below test cases are specific to API related files-------
*/
/*
* Test case for checking whether the functionblock related file has the status properties both
* primitive and object with the setters and getters
*
*/
@Test
public void checkAPIStatusPropertiesInFunctionBlock() throws Exception {
IGenerationResult generationResult = eclipseArduinoGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
org.eclipse.vorto.plugin.generator.utils.Generated generatedfile = zipFileReader(generationResult, "StatusPropertiesFunctionBlock.cpp", ".cpp");
File defaultFile = new File(getClass().getClassLoader().getResource("defaultFileFormat/StatusPropertiesFunctionBlock.cpp").toURI());
assertEquals(TestUtils.normalizeEOL(IOUtils.toString(FileUtils.openInputStream(defaultFile))), TestUtils.normalizeEOL(new String(generatedfile.getContent(), "utf-8")));
}
Aggregations