Search in sources :

Example 16 with Property

use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project kie-wb-common by kiegroup.

the class MultipleInstanceActivityPropertyWriterTest method setUp.

@Before
public void setUp() {
    activity = Factories.bpmn2.createUserTask();
    activity.setId(ACTIVITY_ID);
    variableScope = mock(VariableScope.class);
    VariableScope.Variable variable = mock(VariableScope.Variable.class);
    when(variableScope.lookup(PROPERTY_ID)).thenReturn(Optional.of(variable));
    Property property = mockProperty(PROPERTY_ID, ITEM_ID);
    when(variable.getTypedIdentifier()).thenReturn(property);
    writer = new MultipleInstanceActivityPropertyWriter(activity, variableScope, new HashSet<>());
}
Also used : Property(org.eclipse.bpmn2.Property) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 17 with Property

use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testMarshallProcessVariables.

@Test
public void testMarshallProcessVariables() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 7, 7);
    Definitions definitions = new DefinitionsConverter(diagram.getGraph()).toDefinitions();
    assertNotNull(definitions);
    List<RootElement> rootElements = definitions.getRootElements();
    assertNotNull(rootElements);
    assertItemExists(rootElements, "_employeeItem", "java.lang.String");
    assertItemExists(rootElements, "_reasonItem", "java.lang.String");
    assertItemExists(rootElements, "_performanceItem", "java.lang.String");
    Process process = getProcess(definitions);
    assertNotNull(process);
    List<Property> properties = process.getProperties();
    assertNotNull(properties);
    assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
    assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
    assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) RootElement(org.eclipse.bpmn2.RootElement) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Process(org.eclipse.bpmn2.Process) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) Property(org.eclipse.bpmn2.Property) Test(org.junit.Test)

Example 18 with Property

use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project kie-wb-common by kiegroup.

the class OutputAssignmentReaderTest method mockProperty.

private static Property mockProperty(String id, String name) {
    Property property = mock(Property.class);
    when(property.getId()).thenReturn(id);
    when(property.getName()).thenReturn(name);
    return property;
}
Also used : Property(org.eclipse.bpmn2.Property)

Example 19 with Property

use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project smarthome by eclipse.

the class HomieImplementationTests method retrieveAttributes.

@SuppressWarnings("null")
@Test
public void retrieveAttributes() throws InterruptedException, ExecutionException {
    assertThat(connection.hasSubscribers(), is(false));
    Node node = new Node(deviceTopic, "testnode", ThingChannelConstants.testHomieThing, callback, new NodeAttributes());
    Property property = spy(new Property(deviceTopic + "/testnode", node, "temperature", callback, new PropertyAttributes()));
    // Create a scheduler
    ScheduledExecutorService scheduler = new ScheduledThreadPoolExecutor(4);
    property.subscribe(connection, scheduler, 100).get();
    assertThat(property.attributes.settable, is(true));
    assertThat(property.attributes.retained, is(true));
    assertThat(property.attributes.name, is("Testprop"));
    assertThat(property.attributes.unit, is("°C"));
    assertThat(property.attributes.datatype, is(DataTypeEnum.float_));
    assertThat(property.attributes.format, is("-100:100"));
    verify(property).attributesReceived();
    // Receive property value
    ChannelState channelState = spy(property.getChannelState());
    PropertyHelper.setChannelState(property, channelState);
    property.startChannel(connection, scheduler, 200).get();
    verify(channelState).start(any(), any(), anyInt());
    verify(channelState).processMessage(any(), any());
    verify(callback).updateChannelState(any(), any());
    assertThat(property.getChannelState().getCache().getChannelState(), is(new DecimalType(10)));
    property.stop().get();
    assertThat(connection.hasSubscribers(), is(false));
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ChannelState(org.eclipse.smarthome.binding.mqtt.generic.internal.generic.ChannelState) PropertyAttributes(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.PropertyAttributes) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) Node(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node) NodeAttributes(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.NodeAttributes) DecimalType(org.eclipse.smarthome.core.library.types.DecimalType) Property(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Example 20 with Property

use of org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property in project smarthome by eclipse.

the class HomieThingHandlerTests method handleCommandRefresh.

@SuppressWarnings("null")
@Test
public void handleCommandRefresh() {
    // Create mocked homie device tree with one node and one read-only property
    Node node = thingHandler.device.createNode("node", spy(new NodeAttributes()));
    doReturn(future).when(node.attributes).subscribeAndReceive(any(), any(), anyString(), any(), anyInt());
    doReturn(future).when(node.attributes).unsubscribe();
    node.attributes.name = "testnode";
    Property property = node.createProperty("property", spy(new PropertyAttributes()));
    doReturn(future).when(property.attributes).subscribeAndReceive(any(), any(), anyString(), any(), anyInt());
    doReturn(future).when(property.attributes).unsubscribe();
    property.attributes.name = "testprop";
    property.attributes.datatype = DataTypeEnum.string_;
    property.attributes.settable = false;
    property.attributesReceived();
    node.properties.put(property.propertyID, property);
    thingHandler.device.nodes.put(node.nodeID, node);
    thingHandler.connection = connection;
    thingHandler.handleCommand(property.channelUID, RefreshType.REFRESH);
    verify(callback).stateUpdated(argThat(arg -> property.channelUID.equals(arg)), argThat(arg -> property.getChannelState().getCache().getChannelState().equals(arg)));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Channel(org.eclipse.smarthome.core.thing.Channel) ArgumentMatchers(org.mockito.ArgumentMatchers) ScheduledFuture(java.util.concurrent.ScheduledFuture) ChannelState(org.eclipse.smarthome.binding.mqtt.generic.internal.generic.ChannelState) Command(org.eclipse.smarthome.core.types.Command) MockitoAnnotations(org.mockito.MockitoAnnotations) Nullable(org.eclipse.jdt.annotation.Nullable) Map(java.util.Map) AbstractMqttAttributeClass(org.eclipse.smarthome.binding.mqtt.generic.internal.mapping.AbstractMqttAttributeClass) Thing(org.eclipse.smarthome.core.thing.Thing) StringType(org.eclipse.smarthome.core.library.types.StringType) MqttBindingConstants(org.eclipse.smarthome.binding.mqtt.generic.internal.MqttBindingConstants) Device(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Device) MqttChannelTypeProvider(org.eclipse.smarthome.binding.mqtt.generic.internal.generic.MqttChannelTypeProvider) Configuration(org.eclipse.smarthome.config.core.Configuration) ChannelStateHelper(org.eclipse.smarthome.binding.mqtt.generic.internal.generic.ChannelStateHelper) DeviceAttributes(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.DeviceAttributes) ReadyState(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.DeviceAttributes.ReadyState) MqttBrokerConnection(org.eclipse.smarthome.io.transport.mqtt.MqttBrokerConnection) RefreshType(org.eclipse.smarthome.core.types.RefreshType) List(java.util.List) NonNull(org.eclipse.jdt.annotation.NonNull) ChildMap(org.eclipse.smarthome.binding.mqtt.generic.internal.tools.ChildMap) ThingStatus(org.eclipse.smarthome.core.thing.ThingStatus) Mock(org.mockito.Mock) TypeParser(org.eclipse.smarthome.core.types.TypeParser) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) AbstractBrokerHandler(org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ChannelKind(org.eclipse.smarthome.core.thing.type.ChannelKind) NodeAttributes(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.NodeAttributes) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ThingChannelConstants.testHomieThing(org.eclipse.smarthome.binding.mqtt.generic.internal.handler.ThingChannelConstants.testHomieThing) Before(org.junit.Before) ThingHandlerCallback(org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback) Value(org.eclipse.smarthome.binding.mqtt.generic.internal.values.Value) DelayedBatchProcessing(org.eclipse.smarthome.binding.mqtt.generic.internal.tools.DelayedBatchProcessing) Property(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property) ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo) Test(org.junit.Test) SubscribeFieldToMQTTtopic(org.eclipse.smarthome.binding.mqtt.generic.internal.mapping.SubscribeFieldToMQTTtopic) Field(java.lang.reflect.Field) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) PropertyAttributes(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.PropertyAttributes) Mockito(org.mockito.Mockito) Node(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node) ThingBuilder(org.eclipse.smarthome.core.thing.binding.builder.ThingBuilder) ThingStatusDetail(org.eclipse.smarthome.core.thing.ThingStatusDetail) DataTypeEnum(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.PropertyAttributes.DataTypeEnum) Assert(org.junit.Assert) PropertyAttributes(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.PropertyAttributes) Node(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node) NodeAttributes(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.NodeAttributes) Property(org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property) Test(org.junit.Test)

Aggregations

Property (org.eclipse.bpmn2.Property)21 Test (org.junit.Test)8 Property (io.atlasmap.v2.Property)7 ArrayList (java.util.ArrayList)7 Node (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node)7 Process (org.eclipse.bpmn2.Process)6 Property (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Property)6 DataObject (org.eclipse.bpmn2.DataObject)5 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)5 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)5 RootElement (org.eclipse.bpmn2.RootElement)5 NodeAttributes (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.NodeAttributes)5 PropertyAttributes (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.PropertyAttributes)5 Properties (io.atlasmap.v2.Properties)4 List (java.util.List)4 DataInput (org.eclipse.bpmn2.DataInput)4 DeclarationList (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.DeclarationList)4 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)3 DataOutput (org.eclipse.bpmn2.DataOutput)3 FlowElement (org.eclipse.bpmn2.FlowElement)3