mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-02-09 18:36:50 +01:00
More code cleanups (#3975)
While cleaning up the code I found a some more code to cleanup: * Remove unnecessary boxing * Use `contains(..)` instead of `indexOf(..) != -1` * Use `assertInstanceOf` in tests * Make expensive trace logging conditional * Remove redundant constructor * Replace `collect(Collectors.toUnmodifiableList())` with `toList()` * Replace `filter(..).count() == 0L` with `noneMatch(..)` * Replace `filter(..).count() > 0` with `anyMatch(..)` Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
parent
0e03943e48
commit
ba5647b871
@ -89,7 +89,7 @@ public class AudioWaveUtils {
|
|||||||
*/
|
*/
|
||||||
public static void removeFMT(InputStream data) throws IOException {
|
public static void removeFMT(InputStream data) throws IOException {
|
||||||
DataInputStream dataInputStream = new DataInputStream(data);
|
DataInputStream dataInputStream = new DataInputStream(data);
|
||||||
Integer nextInt = dataInputStream.readInt();
|
int nextInt = dataInputStream.readInt();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (nextInt != DATA_MAGIC && i < 200) {
|
while (nextInt != DATA_MAGIC && i < 200) {
|
||||||
nextInt = dataInputStream.readInt();
|
nextInt = dataInputStream.readInt();
|
||||||
|
@ -328,7 +328,7 @@ public class AutomationCommandList extends AutomationCommand {
|
|||||||
return templates;
|
return templates;
|
||||||
} else {
|
} else {
|
||||||
for (String templateUID : list.keySet()) {
|
for (String templateUID : list.keySet()) {
|
||||||
if (templateUID.indexOf(id) != -1) {
|
if (templateUID.contains(id)) {
|
||||||
templates.add(autoCommands.getTemplate(templateUID, locale));
|
templates.add(autoCommands.getTemplate(templateUID, locale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ public class AutomationCommandList extends AutomationCommand {
|
|||||||
return moduleTypes;
|
return moduleTypes;
|
||||||
} else {
|
} else {
|
||||||
for (String typeUID : list.values()) {
|
for (String typeUID : list.values()) {
|
||||||
if (typeUID.indexOf(id) != -1) {
|
if (typeUID.contains(id)) {
|
||||||
moduleTypes.add(autoCommands.getModuleType(typeUID, locale));
|
moduleTypes.add(autoCommands.getModuleType(typeUID, locale));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ public class AnnotationActionModuleTypeProviderTest extends JavaTest {
|
|||||||
assertTrue(types.contains(TEST_ACTION_TYPE_ID));
|
assertTrue(types.contains(TEST_ACTION_TYPE_ID));
|
||||||
|
|
||||||
ModuleType mt = prov.getModuleType(TEST_ACTION_TYPE_ID, null);
|
ModuleType mt = prov.getModuleType(TEST_ACTION_TYPE_ID, null);
|
||||||
assertTrue(mt instanceof ActionType);
|
assertInstanceOf(ActionType.class, mt);
|
||||||
|
|
||||||
ActionType at = (ActionType) mt;
|
ActionType at = (ActionType) mt;
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public class AnnotatedThingActionModuleTypeProviderTest extends JavaTest {
|
|||||||
assertTrue(types.contains(TEST_ACTION_TYPE_ID));
|
assertTrue(types.contains(TEST_ACTION_TYPE_ID));
|
||||||
|
|
||||||
ModuleType mt = prov.getModuleType(TEST_ACTION_TYPE_ID, null);
|
ModuleType mt = prov.getModuleType(TEST_ACTION_TYPE_ID, null);
|
||||||
assertTrue(mt instanceof ActionType);
|
assertInstanceOf(ActionType.class, mt);
|
||||||
|
|
||||||
ActionType at = (ActionType) mt;
|
ActionType at = (ActionType) mt;
|
||||||
|
|
||||||
|
@ -249,8 +249,10 @@ public class IpAddonFinder extends BaseAddonFinder {
|
|||||||
.configureBlocking(false);
|
.configureBlocking(false);
|
||||||
|
|
||||||
byte[] requestArray = buildRequestArray(channel, Objects.toString(request));
|
byte[] requestArray = buildRequestArray(channel, Objects.toString(request));
|
||||||
logger.trace("{}: {}", candidate.getUID(),
|
if (logger.isTraceEnabled()) {
|
||||||
HexFormat.of().withDelimiter(" ").formatHex(requestArray));
|
logger.trace("{}: {}", candidate.getUID(),
|
||||||
|
HexFormat.of().withDelimiter(" ").formatHex(requestArray));
|
||||||
|
}
|
||||||
|
|
||||||
channel.send(ByteBuffer.wrap(requestArray),
|
channel.send(ByteBuffer.wrap(requestArray),
|
||||||
new InetSocketAddress(destIp, destPort));
|
new InetSocketAddress(destIp, destPort));
|
||||||
|
@ -14,7 +14,6 @@ package org.openhab.core.config.discovery.addon.process;
|
|||||||
|
|
||||||
import static org.openhab.core.config.discovery.addon.AddonFinderConstants.ADDON_SUGGESTION_FINDER;
|
import static org.openhab.core.config.discovery.addon.AddonFinderConstants.ADDON_SUGGESTION_FINDER;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -28,7 +27,6 @@ import org.openhab.core.addon.AddonInfo;
|
|||||||
import org.openhab.core.addon.AddonMatchProperty;
|
import org.openhab.core.addon.AddonMatchProperty;
|
||||||
import org.openhab.core.config.discovery.addon.AddonFinder;
|
import org.openhab.core.config.discovery.addon.AddonFinder;
|
||||||
import org.openhab.core.config.discovery.addon.BaseAddonFinder;
|
import org.openhab.core.config.discovery.addon.BaseAddonFinder;
|
||||||
import org.osgi.service.component.annotations.Activate;
|
|
||||||
import org.osgi.service.component.annotations.Component;
|
import org.osgi.service.component.annotations.Component;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -51,10 +49,6 @@ public class ProcessAddonFinder extends BaseAddonFinder {
|
|||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ProcessAddonFinder.class);
|
private final Logger logger = LoggerFactory.getLogger(ProcessAddonFinder.class);
|
||||||
|
|
||||||
@Activate
|
|
||||||
public ProcessAddonFinder() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// get list of running processes visible to openHAB,
|
// get list of running processes visible to openHAB,
|
||||||
// also tries to mitigate differences on different operating systems
|
// also tries to mitigate differences on different operating systems
|
||||||
String getProcessCommandProcess(ProcessHandle h) {
|
String getProcessCommandProcess(ProcessHandle h) {
|
||||||
@ -77,7 +71,7 @@ public class ProcessAddonFinder extends BaseAddonFinder {
|
|||||||
public Set<AddonInfo> getSuggestedAddons() {
|
public Set<AddonInfo> getSuggestedAddons() {
|
||||||
logger.trace("ProcessAddonFinder::getSuggestedAddons");
|
logger.trace("ProcessAddonFinder::getSuggestedAddons");
|
||||||
Set<AddonInfo> result = new HashSet<>();
|
Set<AddonInfo> result = new HashSet<>();
|
||||||
Set<String> processList = Collections.emptySet();
|
Set<String> processList;
|
||||||
try {
|
try {
|
||||||
processList = ProcessHandle.allProcesses().map(this::getProcessCommandProcess)
|
processList = ProcessHandle.allProcesses().map(this::getProcessCommandProcess)
|
||||||
.filter(Predicate.not(String::isEmpty)).collect(Collectors.toUnmodifiableSet());
|
.filter(Predicate.not(String::isEmpty)).collect(Collectors.toUnmodifiableSet());
|
||||||
@ -92,7 +86,7 @@ public class ProcessAddonFinder extends BaseAddonFinder {
|
|||||||
|
|
||||||
List<AddonMatchProperty> matchProperties = method.getMatchProperties();
|
List<AddonMatchProperty> matchProperties = method.getMatchProperties();
|
||||||
List<AddonMatchProperty> commands = matchProperties.stream()
|
List<AddonMatchProperty> commands = matchProperties.stream()
|
||||||
.filter(amp -> COMMAND.equals(amp.getName())).collect(Collectors.toUnmodifiableList());
|
.filter(amp -> COMMAND.equals(amp.getName())).toList();
|
||||||
|
|
||||||
if (matchProperties.size() != commands.size()) {
|
if (matchProperties.size() != commands.size()) {
|
||||||
logger.warn("Add-on '{}' addon.xml file contains unsupported 'match-property'", candidate.getUID());
|
logger.warn("Add-on '{}' addon.xml file contains unsupported 'match-property'", candidate.getUID());
|
||||||
|
@ -77,7 +77,7 @@ public class UpnpAddonFinder extends BaseAddonFinder implements RegistryListener
|
|||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(UpnpAddonFinder.class);
|
private final Logger logger = LoggerFactory.getLogger(UpnpAddonFinder.class);
|
||||||
private final Map<String, RemoteDevice> devices = new ConcurrentHashMap<>();
|
private final Map<String, RemoteDevice> devices = new ConcurrentHashMap<>();
|
||||||
private UpnpService upnpService;
|
private final UpnpService upnpService;
|
||||||
|
|
||||||
@Activate
|
@Activate
|
||||||
public UpnpAddonFinder(@Reference UpnpService upnpService) {
|
public UpnpAddonFinder(@Reference UpnpService upnpService) {
|
||||||
|
@ -114,12 +114,12 @@ public class PersistentInboxTest {
|
|||||||
when(thingRegistryMock.get(eq(THING_UID))).thenReturn(thing);
|
when(thingRegistryMock.get(eq(THING_UID))).thenReturn(thing);
|
||||||
when(thingProviderMock.get(eq(THING_UID))).thenReturn(thing);
|
when(thingProviderMock.get(eq(THING_UID))).thenReturn(thing);
|
||||||
|
|
||||||
assertTrue(thing.getConfiguration().get("foo") instanceof String);
|
assertInstanceOf(String.class, thing.getConfiguration().get("foo"));
|
||||||
|
|
||||||
inbox.activate();
|
inbox.activate();
|
||||||
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", 3).build());
|
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", 3).build());
|
||||||
|
|
||||||
assertTrue(thing.getConfiguration().get("foo") instanceof String);
|
assertInstanceOf(String.class, thing.getConfiguration().get("foo"));
|
||||||
// thing updated if managed
|
// thing updated if managed
|
||||||
assertEquals("3", thing.getConfiguration().get("foo"));
|
assertEquals("3", thing.getConfiguration().get("foo"));
|
||||||
}
|
}
|
||||||
@ -131,12 +131,12 @@ public class PersistentInboxTest {
|
|||||||
configureConfigDescriptionRegistryMock("foo", Type.TEXT);
|
configureConfigDescriptionRegistryMock("foo", Type.TEXT);
|
||||||
when(thingRegistryMock.get(eq(THING_UID))).thenReturn(thing);
|
when(thingRegistryMock.get(eq(THING_UID))).thenReturn(thing);
|
||||||
|
|
||||||
assertTrue(thing.getConfiguration().get("foo") instanceof String);
|
assertInstanceOf(String.class, thing.getConfiguration().get("foo"));
|
||||||
|
|
||||||
inbox.activate();
|
inbox.activate();
|
||||||
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", 3).build());
|
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty("foo", 3).build());
|
||||||
|
|
||||||
assertTrue(thing.getConfiguration().get("foo") instanceof String);
|
assertInstanceOf(String.class, thing.getConfiguration().get("foo"));
|
||||||
// thing not updated if unmanaged
|
// thing not updated if unmanaged
|
||||||
assertEquals("1", thing.getConfiguration().get("foo"));
|
assertEquals("1", thing.getConfiguration().get("foo"));
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ public class PersistentInboxTest {
|
|||||||
inbox.approve(THING_UID, "Test", null);
|
inbox.approve(THING_UID, "Test", null);
|
||||||
|
|
||||||
assertEquals(THING_UID, lastAddedThing.getUID());
|
assertEquals(THING_UID, lastAddedThing.getUID());
|
||||||
assertTrue(lastAddedThing.getConfiguration().get("foo") instanceof String);
|
assertInstanceOf(String.class, lastAddedThing.getConfiguration().get("foo"));
|
||||||
assertEquals("3", lastAddedThing.getConfiguration().get("foo"));
|
assertEquals("3", lastAddedThing.getConfiguration().get("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ public class PersistentInboxTest {
|
|||||||
inbox.approve(THING_UID, "Test", THING_OTHER_ID);
|
inbox.approve(THING_UID, "Test", THING_OTHER_ID);
|
||||||
|
|
||||||
assertEquals(THING_OTHER_UID, lastAddedThing.getUID());
|
assertEquals(THING_OTHER_UID, lastAddedThing.getUID());
|
||||||
assertTrue(lastAddedThing.getConfiguration().get("foo") instanceof String);
|
assertInstanceOf(String.class, lastAddedThing.getConfiguration().get("foo"));
|
||||||
assertEquals("3", lastAddedThing.getConfiguration().get("foo"));
|
assertEquals("3", lastAddedThing.getConfiguration().get("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,7 +934,7 @@ public class ModbusManagerImpl implements ModbusManager {
|
|||||||
|
|
||||||
private void maybeCloseConnections(ModbusSlaveEndpoint endpoint) {
|
private void maybeCloseConnections(ModbusSlaveEndpoint endpoint) {
|
||||||
boolean lastCommWithThisEndpointWasRemoved = communicationInterfaces.stream()
|
boolean lastCommWithThisEndpointWasRemoved = communicationInterfaces.stream()
|
||||||
.filter(comm -> comm.endpoint.equals(endpoint)).count() == 0L;
|
.noneMatch(comm -> comm.endpoint.equals(endpoint));
|
||||||
if (lastCommWithThisEndpointWasRemoved) {
|
if (lastCommWithThisEndpointWasRemoved) {
|
||||||
// Since last communication interface pointing to this endpoint was closed, we can clean up resources
|
// Since last communication interface pointing to this endpoint was closed, we can clean up resources
|
||||||
// and disconnect connections.
|
// and disconnect connections.
|
||||||
|
@ -169,7 +169,7 @@ public class SmokeTest extends IntegrationTestSupport {
|
|||||||
|
|
||||||
assertThat(okCount.get(), is(equalTo(0)));
|
assertThat(okCount.get(), is(equalTo(0)));
|
||||||
assertThat(errorCount.get(), is(equalTo(1)));
|
assertThat(errorCount.get(), is(equalTo(1)));
|
||||||
assertTrue(lastError.get() instanceof ModbusSlaveErrorResponseException, lastError.toString());
|
assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ public class SmokeTest extends IntegrationTestSupport {
|
|||||||
|
|
||||||
assertThat(okCount.get(), is(equalTo(0)));
|
assertThat(okCount.get(), is(equalTo(0)));
|
||||||
assertThat(errorCount.get(), is(equalTo(1)));
|
assertThat(errorCount.get(), is(equalTo(1)));
|
||||||
assertTrue(lastError.get() instanceof ModbusConnectionException, lastError.toString());
|
assertInstanceOf(ModbusConnectionException.class, lastError.get(), lastError.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ public class SmokeTest extends IntegrationTestSupport {
|
|||||||
assertTrue(callbackCalled.await(15, TimeUnit.SECONDS));
|
assertTrue(callbackCalled.await(15, TimeUnit.SECONDS));
|
||||||
assertThat(okCount.get(), is(equalTo(0)));
|
assertThat(okCount.get(), is(equalTo(0)));
|
||||||
assertThat(lastError.toString(), errorCount.get(), is(equalTo(1)));
|
assertThat(lastError.toString(), errorCount.get(), is(equalTo(1)));
|
||||||
assertTrue(lastError.get() instanceof ModbusSlaveIOException, lastError.toString());
|
assertInstanceOf(ModbusSlaveIOException.class, lastError.get(), lastError.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ public class SmokeTest extends IntegrationTestSupport {
|
|||||||
assertTrue(callbackCalled.await(60, TimeUnit.SECONDS));
|
assertTrue(callbackCalled.await(60, TimeUnit.SECONDS));
|
||||||
|
|
||||||
assertThat(unexpectedCount.get(), is(equalTo(0)));
|
assertThat(unexpectedCount.get(), is(equalTo(0)));
|
||||||
assertTrue(lastError.get() instanceof ModbusSlaveErrorResponseException, lastError.toString());
|
assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString());
|
||||||
|
|
||||||
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
||||||
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
|
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
|
||||||
@ -555,7 +555,7 @@ public class SmokeTest extends IntegrationTestSupport {
|
|||||||
assertTrue(callbackCalled.await(60, TimeUnit.SECONDS));
|
assertTrue(callbackCalled.await(60, TimeUnit.SECONDS));
|
||||||
|
|
||||||
assertThat(unexpectedCount.get(), is(equalTo(0)));
|
assertThat(unexpectedCount.get(), is(equalTo(0)));
|
||||||
assertTrue(lastError.get() instanceof ModbusSlaveErrorResponseException, lastError.toString());
|
assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString());
|
||||||
|
|
||||||
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
||||||
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
|
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
|
||||||
|
@ -173,7 +173,7 @@ public class MqttBrokerConnectionTests extends JavaTest {
|
|||||||
"MqttBrokerConnectionTests");
|
"MqttBrokerConnectionTests");
|
||||||
|
|
||||||
// Check if the default policy is set and that the broker within the policy is set.
|
// Check if the default policy is set and that the broker within the policy is set.
|
||||||
assertTrue(connection.getReconnectStrategy() instanceof PeriodicReconnectStrategy);
|
assertInstanceOf(PeriodicReconnectStrategy.class, connection.getReconnectStrategy());
|
||||||
AbstractReconnectStrategy p = connection.getReconnectStrategy();
|
AbstractReconnectStrategy p = connection.getReconnectStrategy();
|
||||||
assertThat(p.getBrokerConnection(), equalTo(connection));
|
assertThat(p.getBrokerConnection(), equalTo(connection));
|
||||||
}
|
}
|
||||||
|
@ -70,12 +70,10 @@ public class SerialPortRegistry {
|
|||||||
final Predicate<SerialPortProvider> filter;
|
final Predicate<SerialPortProvider> filter;
|
||||||
if (scheme != null) {
|
if (scheme != null) {
|
||||||
// Get port providers which accept exactly the port with its scheme.
|
// Get port providers which accept exactly the port with its scheme.
|
||||||
filter = provider -> provider.getAcceptedProtocols().filter(prot -> prot.getScheme().equals(scheme))
|
filter = provider -> provider.getAcceptedProtocols().anyMatch(prot -> prot.getScheme().equals(scheme));
|
||||||
.count() > 0;
|
|
||||||
} else {
|
} else {
|
||||||
// Get port providers which accept the same type (local, net)
|
// Get port providers which accept the same type (local, net)
|
||||||
filter = provider -> provider.getAcceptedProtocols().filter(prot -> prot.getPathType().equals(pathType))
|
filter = provider -> provider.getAcceptedProtocols().anyMatch(prot -> prot.getPathType().equals(pathType));
|
||||||
.count() > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return portCreators.stream().filter(filter).toList();
|
return portCreators.stream().filter(filter).toList();
|
||||||
|
@ -195,7 +195,7 @@ public class SemanticTagRegistryImpl extends AbstractRegistry<SemanticTag, Strin
|
|||||||
+ "': only Equipment, Location, Point and Property are allowed as root tags.");
|
+ "': only Equipment, Location, Point and Property are allowed as root tags.");
|
||||||
}
|
}
|
||||||
type = uid;
|
type = uid;
|
||||||
className = newTag.getClass().getName();
|
className = newTag.getName();
|
||||||
} else {
|
} else {
|
||||||
String name = uid.substring(lastSeparator + 1);
|
String name = uid.substring(lastSeparator + 1);
|
||||||
String parentId = uid.substring(0, lastSeparator);
|
String parentId = uid.substring(0, lastSeparator);
|
||||||
@ -252,7 +252,7 @@ public class SemanticTagRegistryImpl extends AbstractRegistry<SemanticTag, Strin
|
|||||||
private void addTagSet(String tagId, Class<? extends Tag> tagSet) {
|
private void addTagSet(String tagId, Class<? extends Tag> tagSet) {
|
||||||
logger.trace("addTagSet {}", tagId);
|
logger.trace("addTagSet {}", tagId);
|
||||||
String id = tagId;
|
String id = tagId;
|
||||||
while (id.indexOf("_") != -1) {
|
while (id.contains("_")) {
|
||||||
SemanticTags.addTagSet(id, tagSet);
|
SemanticTags.addTagSet(id, tagSet);
|
||||||
id = id.substring(id.indexOf("_") + 1);
|
id = id.substring(id.indexOf("_") + 1);
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ public class SemanticTagRegistryImpl extends AbstractRegistry<SemanticTag, Strin
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String id = tagId;
|
String id = tagId;
|
||||||
while (id.indexOf("_") != -1) {
|
while (id.contains("_")) {
|
||||||
SemanticTags.removeTagSet(id, tagSet);
|
SemanticTags.removeTagSet(id, tagSet);
|
||||||
id = id.substring(id.indexOf("_") + 1);
|
id = id.substring(id.indexOf("_") + 1);
|
||||||
}
|
}
|
||||||
|
@ -74,14 +74,14 @@ public class JsonStorageTest extends JavaTest {
|
|||||||
DummyObject dummy = objectStorage.get("DummyObject");
|
DummyObject dummy = objectStorage.get("DummyObject");
|
||||||
|
|
||||||
assertNotNull(dummy);
|
assertNotNull(dummy);
|
||||||
assertTrue(dummy.configuration.get("testShort") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testShort"));
|
||||||
assertTrue(dummy.configuration.get("testInt") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testInt"));
|
||||||
assertTrue(dummy.configuration.get("testLong") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testLong"));
|
||||||
assertTrue(dummy.configuration.get("testDouble") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testDouble"));
|
||||||
assertTrue(dummy.configuration.get("testFloat") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testFloat"));
|
||||||
assertTrue(dummy.configuration.get("testBigDecimal") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testBigDecimal"));
|
||||||
assertTrue(dummy.configuration.get("testBoolean") instanceof Boolean);
|
assertInstanceOf(Boolean.class, dummy.configuration.get("testBoolean"));
|
||||||
assertTrue(dummy.configuration.get("testString") instanceof String);
|
assertInstanceOf(String.class, dummy.configuration.get("testString"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -91,14 +91,14 @@ public class JsonStorageTest extends JavaTest {
|
|||||||
DummyObject dummy = objectStorage.get("DummyObject");
|
DummyObject dummy = objectStorage.get("DummyObject");
|
||||||
|
|
||||||
assertNotNull(dummy);
|
assertNotNull(dummy);
|
||||||
assertTrue(dummy.configuration.get("testShort") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testShort"));
|
||||||
assertTrue(dummy.configuration.get("testInt") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testInt"));
|
||||||
assertTrue(dummy.configuration.get("testLong") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testLong"));
|
||||||
assertTrue(dummy.configuration.get("testDouble") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testDouble"));
|
||||||
assertTrue(dummy.configuration.get("testFloat") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testFloat"));
|
||||||
assertTrue(dummy.configuration.get("testBigDecimal") instanceof BigDecimal);
|
assertInstanceOf(BigDecimal.class, dummy.configuration.get("testBigDecimal"));
|
||||||
assertTrue(dummy.configuration.get("testBoolean") instanceof Boolean);
|
assertInstanceOf(Boolean.class, dummy.configuration.get("testBoolean"));
|
||||||
assertTrue(dummy.configuration.get("testString") instanceof String);
|
assertInstanceOf(String.class, dummy.configuration.get("testString"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -86,7 +86,7 @@ class BaseDynamicCommandDescriptionProviderTest {
|
|||||||
verify(eventPublisherMock, times(1)).post(capture.capture());
|
verify(eventPublisherMock, times(1)).post(capture.capture());
|
||||||
|
|
||||||
Event event = capture.getValue();
|
Event event = capture.getValue();
|
||||||
assertTrue(event instanceof ChannelDescriptionChangedEvent);
|
assertInstanceOf(ChannelDescriptionChangedEvent.class, event);
|
||||||
ChannelDescriptionChangedEvent cdce = (ChannelDescriptionChangedEvent) event;
|
ChannelDescriptionChangedEvent cdce = (ChannelDescriptionChangedEvent) event;
|
||||||
assertEquals(CommonChannelDescriptionField.COMMAND_OPTIONS, cdce.getField());
|
assertEquals(CommonChannelDescriptionField.COMMAND_OPTIONS, cdce.getField());
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class BaseDynamicStateDescriptionProviderTest {
|
|||||||
verify(eventPublisherMock, times(1)).post(capture.capture());
|
verify(eventPublisherMock, times(1)).post(capture.capture());
|
||||||
|
|
||||||
Event event = capture.getValue();
|
Event event = capture.getValue();
|
||||||
assertTrue(event instanceof ChannelDescriptionChangedEvent);
|
assertInstanceOf(ChannelDescriptionChangedEvent.class, event);
|
||||||
ChannelDescriptionChangedEvent cdce = (ChannelDescriptionChangedEvent) event;
|
ChannelDescriptionChangedEvent cdce = (ChannelDescriptionChangedEvent) event;
|
||||||
assertEquals(CommonChannelDescriptionField.PATTERN, cdce.getField());
|
assertEquals(CommonChannelDescriptionField.PATTERN, cdce.getField());
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ class BaseDynamicStateDescriptionProviderTest {
|
|||||||
verify(eventPublisherMock, times(1)).post(capture.capture());
|
verify(eventPublisherMock, times(1)).post(capture.capture());
|
||||||
|
|
||||||
Event event = capture.getValue();
|
Event event = capture.getValue();
|
||||||
assertTrue(event instanceof ChannelDescriptionChangedEvent);
|
assertInstanceOf(ChannelDescriptionChangedEvent.class, event);
|
||||||
ChannelDescriptionChangedEvent cdce = (ChannelDescriptionChangedEvent) event;
|
ChannelDescriptionChangedEvent cdce = (ChannelDescriptionChangedEvent) event;
|
||||||
assertEquals(CommonChannelDescriptionField.STATE_OPTIONS, cdce.getField());
|
assertEquals(CommonChannelDescriptionField.STATE_OPTIONS, cdce.getField());
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ public abstract class AbstractFileTransformationService<T> implements Transforma
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void watchSubDirectory(String subDirectory, final WatchService watchService) {
|
private void watchSubDirectory(String subDirectory, final WatchService watchService) {
|
||||||
if (watchedDirectories.indexOf(subDirectory) == -1) {
|
if (!watchedDirectories.contains(subDirectory)) {
|
||||||
String watchedDirectory = getSourcePath() + subDirectory;
|
String watchedDirectory = getSourcePath() + subDirectory;
|
||||||
Path transformFilePath = Paths.get(watchedDirectory);
|
Path transformFilePath = Paths.get(watchedDirectory);
|
||||||
try {
|
try {
|
||||||
|
@ -300,7 +300,7 @@ public class DefaultChartProvider implements ChartProvider {
|
|||||||
} else if (state instanceof OpenClosedType) {
|
} else if (state instanceof OpenClosedType) {
|
||||||
return state == OpenClosedType.CLOSED ? 0 : 1;
|
return state == OpenClosedType.CLOSED ? 0 : 1;
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Unsupported item type in chart: {}", state.getClass().toString());
|
logger.debug("Unsupported item type in chart: {}", state.getClass());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -632,7 +632,7 @@ public class ItemUIRegistryImplTest {
|
|||||||
|
|
||||||
State stateForSlider = uiRegistry.getState(sliderWidget);
|
State stateForSlider = uiRegistry.getState(sliderWidget);
|
||||||
|
|
||||||
assertTrue(stateForSlider instanceof PercentType);
|
assertInstanceOf(PercentType.class, stateForSlider);
|
||||||
|
|
||||||
PercentType pt = (PercentType) stateForSlider;
|
PercentType pt = (PercentType) stateForSlider;
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class ManagedMetadataProviderImpl extends AbstractManagedProvider<Metadat
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Metadata> getAll() {
|
public Collection<Metadata> getAll() {
|
||||||
return super.getAll().stream().map(this::normalizeMetadata).collect(Collectors.toUnmodifiableList());
|
return super.getAll().stream().map(this::normalizeMetadata).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -708,7 +708,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
groupItem.setState(new HSBType("200,80,80"));
|
groupItem.setState(new HSBType("200,80,80"));
|
||||||
groupStateAsPercent = groupItem.getStateAs(PercentType.class);
|
groupStateAsPercent = groupItem.getStateAs(PercentType.class);
|
||||||
|
|
||||||
assertTrue(groupStateAsPercent instanceof PercentType);
|
assertInstanceOf(PercentType.class, groupStateAsPercent);
|
||||||
assertThat(((PercentType) groupStateAsPercent).intValue(), is(80));
|
assertThat(((PercentType) groupStateAsPercent).intValue(), is(80));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -725,7 +725,7 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
groupItem.setState(new PercentType(80));
|
groupItem.setState(new PercentType(80));
|
||||||
groupStateAsPercent = groupItem.getStateAs(PercentType.class);
|
groupStateAsPercent = groupItem.getStateAs(PercentType.class);
|
||||||
|
|
||||||
assertTrue(groupStateAsPercent instanceof PercentType);
|
assertInstanceOf(PercentType.class, groupStateAsPercent);
|
||||||
assertThat(((PercentType) groupStateAsPercent).intValue(), is(80));
|
assertThat(((PercentType) groupStateAsPercent).intValue(), is(80));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -750,11 +750,11 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
assertThat(change.getItemName(), is(groupItem.getName()));
|
assertThat(change.getItemName(), is(groupItem.getName()));
|
||||||
|
|
||||||
State newEventState = change.getItemState();
|
State newEventState = change.getItemState();
|
||||||
assertTrue(newEventState instanceof PercentType);
|
assertInstanceOf(PercentType.class, newEventState);
|
||||||
assertThat(((PercentType) newEventState).intValue(), is(50));
|
assertThat(((PercentType) newEventState).intValue(), is(50));
|
||||||
|
|
||||||
State newGroupState = groupItem.getState();
|
State newGroupState = groupItem.getState();
|
||||||
assertTrue(newGroupState instanceof PercentType);
|
assertInstanceOf(PercentType.class, newGroupState);
|
||||||
assertThat(((PercentType) newGroupState).intValue(), is(50));
|
assertThat(((PercentType) newGroupState).intValue(), is(50));
|
||||||
|
|
||||||
events.clear();
|
events.clear();
|
||||||
@ -770,11 +770,11 @@ public class GroupItemOSGiTest extends JavaOSGiTest {
|
|||||||
assertThat(change.getItemName(), is(groupItem.getName()));
|
assertThat(change.getItemName(), is(groupItem.getName()));
|
||||||
|
|
||||||
newEventState = change.getItemState();
|
newEventState = change.getItemState();
|
||||||
assertTrue(newEventState instanceof PercentType);
|
assertInstanceOf(PercentType.class, newEventState);
|
||||||
assertThat(((PercentType) newEventState).intValue(), is(30));
|
assertThat(((PercentType) newEventState).intValue(), is(30));
|
||||||
|
|
||||||
newGroupState = groupItem.getState();
|
newGroupState = groupItem.getState();
|
||||||
assertTrue(newGroupState instanceof PercentType);
|
assertInstanceOf(PercentType.class, newGroupState);
|
||||||
assertThat(((PercentType) newGroupState).intValue(), is(30));
|
assertThat(((PercentType) newGroupState).intValue(), is(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
ChannelTypeProvider provider = getService(ChannelTypeProvider.class, DefaultSystemChannelTypeProvider.class);
|
ChannelTypeProvider provider = getService(ChannelTypeProvider.class, DefaultSystemChannelTypeProvider.class);
|
||||||
assertTrue(provider instanceof DefaultSystemChannelTypeProvider);
|
assertInstanceOf(DefaultSystemChannelTypeProvider.class, provider);
|
||||||
systemChannelTypeProvider = provider;
|
systemChannelTypeProvider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class SystemProfileI18nOSGiTest extends JavaOSGiTest {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
ProfileTypeProvider provider = getService(ProfileTypeProvider.class, SystemProfileFactory.class);
|
ProfileTypeProvider provider = getService(ProfileTypeProvider.class, SystemProfileFactory.class);
|
||||||
assertTrue(provider instanceof SystemProfileFactory);
|
assertInstanceOf(SystemProfileFactory.class, provider);
|
||||||
systemProfileTypeProvider = provider;
|
systemProfileTypeProvider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class SystemWideChannelTypesTest extends JavaOSGiTest {
|
|||||||
assertThat(channelTypeRegistry, is(notNullValue()));
|
assertThat(channelTypeRegistry, is(notNullValue()));
|
||||||
|
|
||||||
ChannelTypeProvider provider = getService(ChannelTypeProvider.class, DefaultSystemChannelTypeProvider.class);
|
ChannelTypeProvider provider = getService(ChannelTypeProvider.class, DefaultSystemChannelTypeProvider.class);
|
||||||
assertTrue(provider instanceof DefaultSystemChannelTypeProvider);
|
assertInstanceOf(DefaultSystemChannelTypeProvider.class, provider);
|
||||||
systemChannelTypeProvider = provider;
|
systemChannelTypeProvider = provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user