Search in sources :

Example 1 with FunctionblockValue

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

the class TwinPayloadFactoryTest method testCreateRequestSingleFbProperty.

@Test
public void testCreateRequestSingleFbProperty() {
    FunctionblockModel fbm = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.createPrimitiveProperty("value", true, PrimitiveType.FLOAT)).build();
    Infomodel infomodel = Infomodel.Builder(ModelId.fromPrettyFormat("com.acme:TemperatureSensor:1.0.0")).withProperty(ModelProperty.Builder("temperature", fbm).build()).build();
    FunctionblockValue fbValue = new FunctionblockValue(fbm);
    fbValue.withStatusProperty("value", 20.2);
    InfomodelValue infomodelValue = new InfomodelValue(infomodel);
    infomodelValue.withFunctionblock("temperature", fbValue);
    System.out.println(gson.toJson(TwinPayloadFactory.toShadowUpdateRequest(infomodelValue)));
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) FunctionblockValue(org.eclipse.vorto.model.runtime.FunctionblockValue) Infomodel(org.eclipse.vorto.model.Infomodel) InfomodelValue(org.eclipse.vorto.model.runtime.InfomodelValue) Test(org.junit.Test)

Example 2 with FunctionblockValue

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

the class TwinPayloadFactoryTest method testCreateRequestSingleFbPropertyForFeature.

@Test
public void testCreateRequestSingleFbPropertyForFeature() {
    FunctionblockModel fbm = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.createPrimitiveProperty("value", true, PrimitiveType.FLOAT)).build();
    FunctionblockValue fbValue = new FunctionblockValue(fbm);
    fbValue.withStatusProperty("value", 20.2);
    System.out.println(gson.toJson(TwinPayloadFactory.toDittoProtocol(fbValue, "temperature", "com.acme:Sensor-1")));
}
Also used : FunctionblockModel(org.eclipse.vorto.model.FunctionblockModel) FunctionblockValue(org.eclipse.vorto.model.runtime.FunctionblockValue) Test(org.junit.Test)

Example 3 with FunctionblockValue

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

the class JsonMappingLoadTest method builtInConverter3.

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

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

the class JsonMappingLoadTest method builtInConverter2.

@Test
@JUnitPerfTest(threads = THREAD_AMOUNT_2, durationMs = TEST_DURATION_2, rampUpPeriodMs = RAMP_PERIOD, warmUpMs = WARMUP_DURATION_2, maxExecutionsPerSecond = EXECUTIONS_PER_SECOND_2)
public void builtInConverter2() 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 5 with FunctionblockValue

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

Aggregations

FunctionblockValue (org.eclipse.vorto.model.runtime.FunctionblockValue)32 InfomodelValue (org.eclipse.vorto.model.runtime.InfomodelValue)29 Test (org.junit.Test)29 JUnitPerfTest (com.github.noconnor.junitperf.JUnitPerfTest)12 IDataMapper (org.eclipse.vorto.mapping.engine.IDataMapper)12 JavascriptEvalProvider (org.eclipse.vorto.mapping.engine.converter.JavascriptEvalProvider)7 FunctionblockModel (org.eclipse.vorto.model.FunctionblockModel)6 Infomodel (org.eclipse.vorto.model.Infomodel)5 Random (java.util.Random)4 IPayloadDeserializer (org.eclipse.vorto.mapping.engine.decoder.IPayloadDeserializer)3 JSONDeserializer (org.eclipse.vorto.mapping.engine.decoder.JSONDeserializer)3 ModelProperty (org.eclipse.vorto.model.ModelProperty)2 Date (java.util.Date)1 JXPathContext (org.apache.commons.jxpath.JXPathContext)1 JXPathInvalidAccessException (org.apache.commons.jxpath.JXPathInvalidAccessException)1 JXPathNotFoundException (org.apache.commons.jxpath.JXPathNotFoundException)1 MappingException (org.eclipse.vorto.mapping.engine.MappingException)1 BinaryData (org.eclipse.vorto.mapping.engine.model.binary.BinaryData)1 EntityPropertyValue (org.eclipse.vorto.model.runtime.EntityPropertyValue)1 SpecWithArrayPayload (org.eclipse.vorto.service.mapping.spec.SpecWithArrayPayload)1