Search in sources :

Example 76 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project openhab-addons by openhab.

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);
    ThingHandlerHelper.setConnection(thingHandler, connection);
    // we need to set a channel value first, undefined values ignored on REFRESH
    property.getChannelState().getCache().update(new StringType("testString"));
    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) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers(org.mockito.ArgumentMatchers) ScheduledFuture(java.util.concurrent.ScheduledFuture) StringType(org.openhab.core.library.types.StringType) Value(org.openhab.binding.mqtt.generic.values.Value) ReadyState(org.openhab.binding.mqtt.homie.internal.homie300.DeviceAttributes.ReadyState) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Nullable(org.eclipse.jdt.annotation.Nullable) Configuration(org.openhab.core.config.core.Configuration) Device(org.openhab.binding.mqtt.homie.internal.homie300.Device) ThingHandlerCallback(org.openhab.core.thing.binding.ThingHandlerCallback) Map(java.util.Map) TypeParser(org.openhab.core.types.TypeParser) ThingBuilder(org.openhab.core.thing.binding.builder.ThingBuilder) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) DelayedBatchProcessing(org.openhab.binding.mqtt.generic.tools.DelayedBatchProcessing) ThingTypeRegistry(org.openhab.core.thing.type.ThingTypeRegistry) Test(org.junit.jupiter.api.Test) Channel(org.openhab.core.thing.Channel) List(java.util.List) Node(org.openhab.binding.mqtt.homie.internal.homie300.Node) NonNull(org.eclipse.jdt.annotation.NonNull) Strictness(org.mockito.quality.Strictness) MqttBrokerConnection(org.openhab.core.io.transport.mqtt.MqttBrokerConnection) MockitoSettings(org.mockito.junit.jupiter.MockitoSettings) MqttChannelTypeProvider(org.openhab.binding.mqtt.generic.MqttChannelTypeProvider) ThingHandlerHelper(org.openhab.binding.mqtt.homie.ThingHandlerHelper) Mock(org.mockito.Mock) AbstractMqttAttributeClass(org.openhab.binding.mqtt.generic.mapping.AbstractMqttAttributeClass) CompletableFuture(java.util.concurrent.CompletableFuture) AbstractBrokerHandler(org.openhab.binding.mqtt.handler.AbstractBrokerHandler) Checks.requireNonNull(org.eclipse.jdt.annotation.Checks.requireNonNull) ArrayList(java.util.ArrayList) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Thing(org.openhab.core.thing.Thing) Property(org.openhab.binding.mqtt.homie.internal.homie300.Property) ChannelKind(org.openhab.core.thing.type.ChannelKind) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) SubscribeFieldToMQTTtopic(org.openhab.binding.mqtt.generic.mapping.SubscribeFieldToMQTTtopic) NodeAttributes(org.openhab.binding.mqtt.homie.internal.homie300.NodeAttributes) ThingStatusInfo(org.openhab.core.thing.ThingStatusInfo) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) PropertyAttributes(org.openhab.binding.mqtt.homie.internal.homie300.PropertyAttributes) ChannelStateHelper(org.openhab.binding.mqtt.homie.ChannelStateHelper) DeviceAttributes(org.openhab.binding.mqtt.homie.internal.homie300.DeviceAttributes) ThingStatus(org.openhab.core.thing.ThingStatus) Command(org.openhab.core.types.Command) TEST_HOMIE_THING(org.openhab.binding.mqtt.homie.internal.handler.ThingChannelConstants.TEST_HOMIE_THING) DataTypeEnum(org.openhab.binding.mqtt.homie.internal.homie300.PropertyAttributes.DataTypeEnum) RefreshType(org.openhab.core.types.RefreshType) ThingStatusDetail(org.openhab.core.thing.ThingStatusDetail) Field(java.lang.reflect.Field) ChildMap(org.openhab.binding.mqtt.generic.tools.ChildMap) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Mockito(org.mockito.Mockito) ChannelState(org.openhab.binding.mqtt.generic.ChannelState) MqttBindingConstants(org.openhab.binding.mqtt.homie.generic.internal.MqttBindingConstants) Assertions(org.junit.jupiter.api.Assertions) PropertyAttributes(org.openhab.binding.mqtt.homie.internal.homie300.PropertyAttributes) StringType(org.openhab.core.library.types.StringType) Node(org.openhab.binding.mqtt.homie.internal.homie300.Node) NodeAttributes(org.openhab.binding.mqtt.homie.internal.homie300.NodeAttributes) Property(org.openhab.binding.mqtt.homie.internal.homie300.Property) Test(org.junit.jupiter.api.Test)

Example 77 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project JavaData by SaitoAsuk-a.

the class FirstLastLinkList method insertLast.

/**
 * ����һ����㣬��β�����в���
 */
public void insertLast(long value) {
    Node node = new Node(value);
    if (isEmpty()) {
        first = node;
    } else {
        last.next = node;
    }
    last = node;
}
Also used : Node(dataStructure.JunkCourse.ch04.Node)

Example 78 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project JavaData by SaitoAsuk-a.

the class FirstLastLinkList method display.

/**
 * ��ʾ����
 */
public void display() {
    Node current = first;
    while (current != null) {
        current.display();
        current = current.next;
    }
    System.out.println();
}
Also used : Node(dataStructure.JunkCourse.ch04.Node)

Example 79 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project JavaData by SaitoAsuk-a.

the class FirstLastLinkList method insertFirst.

/**
 * ����һ����㣬��ͷ������в���
 */
public void insertFirst(long value) {
    Node node = new Node(value);
    if (isEmpty()) {
        last = node;
    }
    node.next = first;
    first = node;
}
Also used : Node(dataStructure.JunkCourse.ch04.Node)

Example 80 with Node

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Node in project JavaData by SaitoAsuk-a.

the class FirstLastLinkList method deleteFirst.

/**
 * ɾ��һ����㣬��ͷ�������ɾ��
 */
public Node deleteFirst() {
    Node tmp = first;
    if (first.next == null) {
        last = null;
    }
    first = tmp.next;
    return tmp;
}
Also used : Node(dataStructure.JunkCourse.ch04.Node)

Aggregations

Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)52 Test (org.junit.Test)27 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)26 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)21 Date (java.util.Date)18 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)17 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)16 Node (org.flyte.api.v1.Node)15 Test (org.junit.jupiter.api.Test)15 ArrayList (java.util.ArrayList)14 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)14 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)13 TaskNode (org.flyte.api.v1.TaskNode)10 Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)10 List (java.util.List)9 Map (java.util.Map)9 Node (org.eclipse.smarthome.binding.mqtt.generic.internal.convention.homie300.Node)9 Node (org.openhab.binding.mqtt.homie.internal.homie300.Node)9 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)9 Node (ch.ethz.globis.phtree.v16.Node)8