* <p>
* This class tests the commands for the astro thing.
*
- * @author Petar Valchev - Initial implementation
+ * @author Petar Valchev - Initial contribution
* @author Svilen Valkanov - Reworked to plain unit tests
* @author Christoph Weitkamp - Migrated tests to pure Java
*/
* <p>
* This class tests the required configuration for the astro thing.
*
- * @author Petar Valchev - Initial implementation
+ * @author Petar Valchev - Initial contribution
* @author Svilen Valkanov - Reworked to plain unit tests, removed irrelevant tests
* @author Christoph Weitkamp - Migrated tests to pure Java
*/
* Tests for the Astro Channels state
*
* @See {@link AstroParametrizedTestCases}
- * @author Petar Valchev - Initial implementation
+ * @author Petar Valchev - Initial contribution
* @author Svilen Valkanov - Reworked to plain unit tests
* @author Erdoan Hadzhiyusein - Adapted the class to work with the new DateTimeType
* @author Christoph Weitkamp - Migrated tests to pure Java
/**
* Contains some test data used across different tests
*
- * @author Svilen Valkanov - Initial implementation
+ * @author Svilen Valkanov - Initial contribution
* @author Christoph Weitkamp - Migrated tests to pure Java
*/
public final class AstroBindingTestsData {
Thing bridge = getThingRegistry().get(MieleCloudBindingIntegrationTestConstants.BRIDGE_THING_UID);
assertNotNull(bridge);
ThingHandler handler = bridge.getHandler();
- if (handler instanceof MieleBridgeHandler) {
- ((MieleBridgeHandler) handler).onConnectionAlive();
+ if (handler instanceof MieleBridgeHandler mieleBridgeHandler) {
+ mieleBridgeHandler.onConnectionAlive();
}
return null;
}).when(webservice).addConnectionStatusListener(any());
import static org.openhab.binding.mielecloud.internal.util.ReflectionUtil.setPrivate;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.Optional;
.create(MieleCloudBindingConstants.THING_TYPE_BRIDGE,
MieleCloudBindingIntegrationTestConstants.BRIDGE_THING_UID)
.withLabel("Miele@home Account")
- .withConfiguration(
- new Configuration(Collections.singletonMap(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
- MieleCloudBindingIntegrationTestConstants.EMAIL)))
+ .withConfiguration(new Configuration(Map.of(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
+ MieleCloudBindingIntegrationTestConstants.EMAIL)))
.build();
assertNotNull(bridge);
List<Channel> channels = createChannelsForThingHandler(thingTypeUid, thingUid);
Thing thing = ThingBuilder.create(thingTypeUid, thingUid)
- .withConfiguration(new Configuration(Collections
- .singletonMap(MieleCloudBindingConstants.CONFIG_PARAM_DEVICE_IDENTIFIER, deviceIdentifier)))
+ .withConfiguration(new Configuration(
+ Map.of(MieleCloudBindingConstants.CONFIG_PARAM_DEVICE_IDENTIFIER, deviceIdentifier)))
.withBridge(getBridge().getUID()).withChannels(channels).withLabel("DA-6996")
.withProperty("thingTypeVersion", thingTypeVersion).build();
assertNotNull(thing);
import static org.openhab.binding.mielecloud.internal.util.MieleCloudBindingIntegrationTestConstants.*;
import static org.openhab.binding.mielecloud.internal.util.ReflectionUtil.*;
-import java.util.Collections;
+import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Bridge bridge = BridgeBuilder
.create(MieleCloudBindingConstants.THING_TYPE_BRIDGE,
MieleCloudBindingIntegrationTestConstants.BRIDGE_THING_UID)
- .withConfiguration(
- new Configuration(Collections.singletonMap(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
- MieleCloudBindingIntegrationTestConstants.EMAIL)))
+ .withConfiguration(new Configuration(Map.of(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
+ MieleCloudBindingIntegrationTestConstants.EMAIL)))
.withLabel(MIELE_CLOUD_ACCOUNT_LABEL).build();
assertNotNull(bridge);
Bridge bridge = BridgeBuilder
.create(MieleCloudBindingConstants.THING_TYPE_BRIDGE,
MieleCloudBindingIntegrationTestConstants.BRIDGE_THING_UID)
- .withConfiguration(
- new Configuration(Collections.singletonMap(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
- MieleCloudBindingIntegrationTestConstants.EMAIL)))
+ .withConfiguration(new Configuration(Map.of(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
+ MieleCloudBindingIntegrationTestConstants.EMAIL)))
.withLabel(MIELE_CLOUD_ACCOUNT_LABEL).build();
assertNotNull(bridge);
// when:
Thing device = ThingBuilder.create(thingTypeUid, thingUid)
- .withConfiguration(new Configuration(Collections
- .singletonMap(MieleCloudBindingConstants.CONFIG_PARAM_DEVICE_IDENTIFIER, DEVICE_IDENTIFIER)))
+ .withConfiguration(new Configuration(
+ Map.of(MieleCloudBindingConstants.CONFIG_PARAM_DEVICE_IDENTIFIER, DEVICE_IDENTIFIER)))
.withLabel(label).withProperty("thingTypeVersion", thingTypeVersion).build();
assertNotNull(device);
Bridge bridge = BridgeBuilder
.create(MieleCloudBindingConstants.THING_TYPE_BRIDGE,
MieleCloudBindingIntegrationTestConstants.BRIDGE_THING_UID)
- .withConfiguration(
- new Configuration(Collections.singletonMap(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
- MieleCloudBindingIntegrationTestConstants.EMAIL)))
+ .withConfiguration(new Configuration(Map.of(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
+ MieleCloudBindingIntegrationTestConstants.EMAIL)))
.withLabel(MIELE_CLOUD_ACCOUNT_LABEL).build();
assertNotNull(bridge);
import static org.junit.jupiter.api.Assertions.*;
import static org.openhab.binding.mielecloud.internal.util.MieleCloudBindingIntegrationTestConstants.MIELE_CLOUD_ACCOUNT_LABEL;
-import java.util.Collections;
+import java.util.Map;
import java.util.Objects;
import org.eclipse.jdt.annotation.NonNullByDefault;
Bridge bridge = BridgeBuilder
.create(MieleCloudBindingConstants.THING_TYPE_BRIDGE,
MieleCloudBindingIntegrationTestConstants.BRIDGE_THING_UID)
- .withConfiguration(
- new Configuration(Collections.singletonMap(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
- MieleCloudBindingIntegrationTestConstants.EMAIL)))
+ .withConfiguration(new Configuration(Map.of(MieleCloudBindingConstants.CONFIG_PARAM_EMAIL,
+ MieleCloudBindingIntegrationTestConstants.EMAIL)))
.withLabel(MIELE_CLOUD_ACCOUNT_LABEL).build();
assertNotNull(bridge);
import static org.mockito.Mockito.*;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
@Override
public Set<@NonNull String> getSubscribedEventTypes() {
- return Collections.singleton(ItemStateEvent.TYPE);
+ return Set.of(ItemStateEvent.TYPE);
}
@Override
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
-import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
DiscoverComponents discover = spy(new DiscoverComponents(ThingChannelConstants.TEST_HOME_ASSISTANT_THING,
scheduler, channelStateUpdateListener, availabilityTracker, gson, transformationServiceProvider));
- HandlerConfiguration config = new HandlerConfiguration("homeassistant",
- Collections.singletonList("switch/object"));
+ HandlerConfiguration config = new HandlerConfiguration("homeassistant", List.of("switch/object"));
Set<HaID> discoveryIds = new HashSet<>();
discoveryIds.addAll(HaID.fromConfig(config));
import static org.mockito.Mockito.*;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ScheduledExecutorService;
// Start the discovery for 2000ms. Forced timeout after 4000ms.
HaID haID = new HaID(testObjectTopic + "/config");
- CompletableFuture<Void> future = discover.startDiscovery(haConnection, 2000, Collections.singleton(haID), cd)
- .thenRun(() -> {
- }).exceptionally(e -> {
- failure = e;
- return null;
- });
+ CompletableFuture<Void> future = discover.startDiscovery(haConnection, 2000, Set.of(haID), cd).thenRun(() -> {
+ }).exceptionally(e -> {
+ failure = e;
+ return null;
+ });
assertTrue(latch.await(4, TimeUnit.SECONDS));
future.get(5, TimeUnit.SECONDS);
} else {
// test argument is only specifiying the data field in the json payload
// Fill rest of the fields with some valid values
- jsonPayload = "{" + " \"gw_mac\": \"DE:AD:BE:EF:00\"," + " \"rssi\": -82," + " \"aoa\": [],"
- + " \"gwts\": \"1659365432\"," + " \"ts\": \"1659365222\"," + " \"data\": \"" + val + "\","
- + " \"coords\": \"\" }";
+ jsonPayload = """
+ {\
+ "gw_mac": "DE:AD:BE:EF:00",\
+ "rssi": -82,\
+ "aoa": [],\
+ "gwts": "1659365432",\
+ "ts": "1659365222",\
+ "data": "\
+ """ + val + "\"," + " \"coords\": \"\" }";
}
Thing ruuviThing = createRuuviThing("mygwid", topic, 100);
.forEach(channelId -> assertEquals(UnDefType.UNDEF, getItemState.apply(channelId)));
statusUpdateIndex.incrementAndGet();
});
-
}
// Another mqtt update (("minimum values" test vector from
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Override
public Set<@NonNull String> getSubscribedEventTypes() {
- return Collections.singleton(ThingStatusInfoChangedEvent.TYPE);
+ return Set.of(ThingStatusInfoChangedEvent.TYPE);
}
@Override
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
-import java.util.Collections;
import java.util.Locale;
+import java.util.Set;
import java.util.TimeZone;
import org.junit.jupiter.api.AfterAll;
initialize(configuration, channelID, acceptedItemType, null, null);
EventSubscriber eventSubscriberMock = mock(EventSubscriber.class);
- when(eventSubscriberMock.getSubscribedEventTypes()).thenReturn(Collections.singleton(ItemStateEvent.TYPE));
+ when(eventSubscriberMock.getSubscribedEventTypes()).thenReturn(Set.of(ItemStateEvent.TYPE));
registerService(eventSubscriberMock);
if (updateEventType.equals(UpdateEventType.HANDLE_COMMAND)) {
assertThat(result.getThingUID(), is(new ThingUID(thingTypeUid, DEVICE_UDN)));
assertThat(result.getThingTypeUID(), is(thingTypeUid));
assertThat(result.getBridgeUID(), is(nullValue()));
- assertThat(result.getProperties().get(WemoBindingConstants.UDN), is(DEVICE_UDN.toString()));
+ assertThat(result.getProperties().get(WemoBindingConstants.UDN), is(DEVICE_UDN));
assertThat(result.getRepresentationProperty(), is(WemoBindingConstants.UDN));
}
}