use of org.eclipse.vorto.plugin.generator.utils.Generated in project vorto by eclipse.
the class EclipseHonoPythonGeneratorTest method checkAPIGenerationOfEntityModel.
/*
* Test case for checking whether the entity/enum values specified in the input datatype file are
* available.
*
*/
@Test
public void checkAPIGenerationOfEntityModel() throws Exception {
IGenerationResult generationResult = pythonGenerator.generate(modelProvider(), InvocationContext.simpleInvocationContext());
Generated generatedfile = zipFileReader(generationResult, "MySensorApp", ".py");
assertEquals(true, new String(generatedfile.getContent(), "utf-8").contains("unitEnum"));
}
use of org.eclipse.vorto.plugin.generator.utils.Generated in project vorto by eclipse.
the class AbstractGeneratorTest method zipFileReader.
public Generated zipFileReader(IGenerationResult generationResult, String inputTypeName, String fileExtension) throws IOException {
ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(generationResult.getContent()));
ZipEntry entry = null;
Generated generated = null;
while ((entry = zipStream.getNextEntry()) != null) {
String entryName = entry.getName();
if (entryName.contains(inputTypeName)) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] byteBuff = new byte[4096];
int bytesRead = 0;
while ((bytesRead = zipStream.read(byteBuff)) != -1) {
out.write(byteBuff, 0, bytesRead);
}
out.close();
generated = new Generated(inputTypeName + fileExtension, null, out.toByteArray());
zipStream.closeEntry();
}
}
zipStream.close();
return generated;
}
Aggregations