Search in sources :

Example 6 with InfomodelValue

use of org.eclipse.vorto.model.runtime.InfomodelValue in project vorto by eclipse.

the class JsonMappingLoadTest method builtInConverter1.

// // Test Case 2: Built-In Converter
@Test
@JUnitPerfTest(threads = THREAD_AMOUNT_1, durationMs = TEST_DURATION_1, rampUpPeriodMs = RAMP_PERIOD, warmUpMs = WARMUP_DURATION_1, maxExecutionsPerSecond = EXECUTIONS_PER_SECOND_1)
public void builtInConverter1() throws Exception {
    InfomodelValue mappedOutput = testCaseTwoMapper.mapSource(gson.fromJson(testCaseTwoJson, Object.class));
    FunctionblockValue buttonFunctionblockData = mappedOutput.get("button");
    assertEquals(JSON_DATE_FORMAT.format(timestamp), buttonFunctionblockData.getStatusProperty("sensor_value").get().getValue());
}
Also used : FunctionblockValue(org.eclipse.vorto.model.runtime.FunctionblockValue) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test) JUnitPerfTest(com.github.noconnor.junitperf.JUnitPerfTest) JUnitPerfTest(com.github.noconnor.junitperf.JUnitPerfTest)

Example 7 with InfomodelValue

use of org.eclipse.vorto.model.runtime.InfomodelValue in project vorto by eclipse.

the class JsonMappingLoadTest method builtInConverterAndJs1.

// / With Converter
// // Test Case 3: Built-in Converter Function + 1 Javascript Function
@Test
@JUnitPerfTest(threads = THREAD_AMOUNT_1, durationMs = TEST_DURATION_1, rampUpPeriodMs = RAMP_PERIOD, warmUpMs = WARMUP_DURATION_1, maxExecutionsPerSecond = EXECUTIONS_PER_SECOND_1)
public void builtInConverterAndJs1() throws Exception {
    int r = new Random().nextInt(2 + 1);
    InfomodelValue mappedOutput = testCaseThreeMapper.mapSource(gson.fromJson(testCaseThreeJsonInput[r], Object.class));
    FunctionblockValue buttonFunctionblockData = mappedOutput.get("button");
    assertEquals(true, (Boolean) buttonFunctionblockData.getStatusProperty("digital_input_state").get().getValue());
    assertEquals(testCaseThreeOutput[r], buttonFunctionblockData.getStatusProperty("digital_input_count").get().getValue());
    FunctionblockValue voltageFunctionblockData = mappedOutput.get("voltage");
    assertNull(voltageFunctionblockData);
}
Also used : FunctionblockValue(org.eclipse.vorto.model.runtime.FunctionblockValue) Random(java.util.Random) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test) JUnitPerfTest(com.github.noconnor.junitperf.JUnitPerfTest) JUnitPerfTest(com.github.noconnor.junitperf.JUnitPerfTest)

Example 8 with InfomodelValue

use of org.eclipse.vorto.model.runtime.InfomodelValue in project vorto by eclipse.

the class JsonMappingLoadTest method builtInConverterAndJs3.

@Test
@JUnitPerfTest(threads = THREAD_AMOUNT_3, durationMs = TEST_DURATION_3, rampUpPeriodMs = RAMP_PERIOD, warmUpMs = WARMUP_DURATION_3, maxExecutionsPerSecond = EXECUTIONS_PER_SECOND_3)
public void builtInConverterAndJs3() throws Exception {
    int r = new Random().nextInt(2 + 1);
    InfomodelValue mappedOutput = testCaseThreeMapper.mapSource(gson.fromJson(testCaseThreeJsonInput[r], Object.class));
    FunctionblockValue buttonFunctionblockData = mappedOutput.get("button");
    assertEquals(true, (Boolean) buttonFunctionblockData.getStatusProperty("digital_input_state").get().getValue());
    assertEquals(testCaseThreeOutput[r], buttonFunctionblockData.getStatusProperty("digital_input_count").get().getValue());
    FunctionblockValue voltageFunctionblockData = mappedOutput.get("voltage");
    assertNull(voltageFunctionblockData);
}
Also used : FunctionblockValue(org.eclipse.vorto.model.runtime.FunctionblockValue) Random(java.util.Random) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test) JUnitPerfTest(com.github.noconnor.junitperf.JUnitPerfTest) JUnitPerfTest(com.github.noconnor.junitperf.JUnitPerfTest)

Example 9 with InfomodelValue

use of org.eclipse.vorto.model.runtime.InfomodelValue in project vorto by eclipse.

the class JsonMappingLoadTest method withoutConverter2.

@Test
@JUnitPerfTest(threads = THREAD_AMOUNT_2, durationMs = TEST_DURATION_2, rampUpPeriodMs = RAMP_PERIOD, warmUpMs = WARMUP_DURATION_2, maxExecutionsPerSecond = EXECUTIONS_PER_SECOND_2)
public void withoutConverter2() throws Exception {
    int r = new Random().nextInt(2 + 1);
    InfomodelValue mappedOutput = testCaseOneMapper.mapSource(deserializer.deserialize(testCaseOneJsonInput[r]));
    EntityPropertyValue temperatureValue = (EntityPropertyValue) mappedOutput.get("outdoorTemperature").getStatusProperty("value").get();
    assertEquals(testCaseOneOutput[r], temperatureValue.getValue().getPropertyValue("value").get().getValue());
}
Also used : Random(java.util.Random) EntityPropertyValue(org.eclipse.vorto.model.runtime.EntityPropertyValue) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test) JUnitPerfTest(com.github.noconnor.junitperf.JUnitPerfTest) JUnitPerfTest(com.github.noconnor.junitperf.JUnitPerfTest)

Example 10 with InfomodelValue

use of org.eclipse.vorto.model.runtime.InfomodelValue in project vorto by eclipse.

the class MappingSpecJsonReaderTest method testMappingFromJson.

@Test
public void testMappingFromJson() {
    IMappingSpecification spec = IMappingSpecification.newBuilder().fromInputStream(MappingSpecJsonReaderTest.class.getClassLoader().getResourceAsStream("mappingspec.json")).build();
    IDataMapper mapper = IDataMapper.newBuilder().withSpecification(spec).build();
    String json = "{\"t\" : 50}";
    IPayloadDeserializer deserializer = new JSONDeserializer();
    InfomodelValue mappedOutput = mapper.mapSource(deserializer.deserialize(json));
    assertEquals(50.0, ((EntityPropertyValue) mappedOutput.get("outdoorTemperature").getStatusProperty("value").get()).getValue().getPropertyValue("value").get().getValue());
}
Also used : IMappingSpecification(org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification) EntityPropertyValue(org.eclipse.vorto.model.runtime.EntityPropertyValue) IPayloadDeserializer(org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer) IDataMapper(org.eclipse.vorto.mapping.engine.IDataMapper) JSONDeserializer(org.eclipse.vorto.mapping.engine.decoder.JSONDeserializer) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test)

Aggregations

InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)58 Test (org.junit.Test)54 FunctionblockValue (org.eclipse.vorto.model.runtime.FunctionblockValue)29 IDataMapper (org.eclipse.vorto.mapping.engine.IDataMapper)25 JUnitPerfTest (com.github.noconnor.junitperf.JUnitPerfTest)24 JavascriptEvalProvider (org.eclipse.vorto.mapping.engine.converter.JavascriptEvalProvider)10 IPayloadDeserializer (org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer)10 JSONDeserializer (org.eclipse.vorto.mapping.engine.decoder.JSONDeserializer)10 Random (java.util.Random)8 EntityPropertyValue (org.eclipse.vorto.model.runtime.EntityPropertyValue)8 Infomodel (org.eclipse.vorto.model.Infomodel)5 FunctionblockModel (org.eclipse.vorto.model.FunctionblockModel)4 HashMap (java.util.HashMap)3 IMappingSpecification (org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification)3 Gson (com.google.gson.Gson)2 JsonObject (com.google.gson.JsonObject)2 File (java.io.File)2 MappingEngine (org.eclipse.vorto.mapping.engine.MappingEngine)2 BinaryData (org.eclipse.vorto.mapping.engine.model.binary.BinaryData)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1