Search in sources :

Example 1 with EntityPropertyValue

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

the class JsonMappingLoadTest method withoutConverter3.

@Test
@JUnitPerfTest(threads = THREAD_AMOUNT_3, durationMs = TEST_DURATION_3, rampUpPeriodMs = RAMP_PERIOD, warmUpMs = WARMUP_DURATION_3, maxExecutionsPerSecond = EXECUTIONS_PER_SECOND_3)
public void withoutConverter3() 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 2 with EntityPropertyValue

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

the class JsonMappingLoadTest method withoutConverter4.

@Test
@JUnitPerfTest(threads = THREAD_AMOUNT_4, durationMs = TEST_DURATION_4, rampUpPeriodMs = RAMP_PERIOD, warmUpMs = WARMUP_DURATION_4, maxExecutionsPerSecond = EXECUTIONS_PER_SECOND_4)
public void withoutConverter4() 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 3 with EntityPropertyValue

use of org.eclipse.vorto.model.runtime.EntityPropertyValue 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 4 with EntityPropertyValue

use of org.eclipse.vorto.model.runtime.EntityPropertyValue 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)

Example 5 with EntityPropertyValue

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

the class JsonMappingTest method testMapNestedEntityWithCustomFunction.

@Test
public void testMapNestedEntityWithCustomFunction() {
    IDataMapper mapper = IDataMapper.newBuilder().withSpecification(new SpecWithNestedEntityAndCustomFunction()).registerScriptEvalProvider(new JavascriptEvalProvider()).build();
    String json = "{\"clickType\" : \"DOUBLE\"}";
    InfomodelValue mappedOutput = mapper.mapSource(gson.fromJson(json, Object.class));
    FunctionblockValue buttonFunctionblockData = mappedOutput.get("button");
    assertEquals(2, ((EntityPropertyValue) buttonFunctionblockData.getStatusProperty("count").get()).getValue().getPropertyValue("value").get().getValue());
    System.out.println(gson.toJson(mappedOutput.serialize()));
}
Also used : FunctionblockValue(org.eclipse.vorto.model.runtime.FunctionblockValue) EntityPropertyValue(org.eclipse.vorto.model.runtime.EntityPropertyValue) IDataMapper(org.eclipse.vorto.mapping.engine.IDataMapper) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) JavascriptEvalProvider(org.eclipse.vorto.mapping.engine.converter.JavascriptEvalProvider) Test(org.junit.Test)

Aggregations

EntityPropertyValue (org.eclipse.vorto.model.runtime.EntityPropertyValue)8 InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)8 Test (org.junit.Test)8 JUnitPerfTest (com.github.noconnor.junitperf.JUnitPerfTest)4 Random (java.util.Random)4 IDataMapper (org.eclipse.vorto.mapping.engine.IDataMapper)4 IPayloadDeserializer (org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer)3 JSONDeserializer (org.eclipse.vorto.mapping.engine.decoder.JSONDeserializer)3 JavascriptEvalProvider (org.eclipse.vorto.mapping.engine.converter.JavascriptEvalProvider)1 IMappingSpecification (org.eclipse.vorto.mapping.engine.model.spec.IMappingSpecification)1 FunctionblockValue (org.eclipse.vorto.model.runtime.FunctionblockValue)1 SpecWithNestedEntity (org.eclipse.vorto.service.mapping.spec.SpecWithNestedEntity)1 SpecWithTwoFunctionblocksWithNestedEntity (org.eclipse.vorto.service.mapping.spec.SpecWithTwoFunctionblocksWithNestedEntity)1