[modbus] Replace apache commons lang usage with plain java (#10002)

* [modbus] fix item creation in tests

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
This commit is contained in:
Sami Salonen
2021-02-01 13:07:52 +02:00
committed by GitHub
parent 0f8f72dd2e
commit d5e83e395b
3 changed files with 20 additions and 22 deletions

View File

@@ -31,7 +31,6 @@ import java.util.concurrent.ScheduledFuture;
import java.util.function.Consumer;
import java.util.function.Function;
import org.apache.commons.lang.StringUtils;
import org.hamcrest.Matcher;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
@@ -60,7 +59,6 @@ import org.openhab.core.io.transport.modbus.endpoint.ModbusSlaveEndpoint;
import org.openhab.core.io.transport.modbus.endpoint.ModbusTCPSlaveEndpoint;
import org.openhab.core.items.GenericItem;
import org.openhab.core.items.Item;
import org.openhab.core.library.items.DateTimeItem;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType;
@@ -191,6 +189,7 @@ public class ModbusDataHandlerTest extends AbstractModbusOSGiTest {
Map<String, ChannelUID> toBeLinked = new HashMap<>();
for (Entry<String, String> entry : CHANNEL_TO_ACCEPTED_TYPE.entrySet()) {
String channelId = entry.getKey();
// accepted item type
String channelAcceptedType = entry.getValue();
ChannelUID channelUID = new ChannelUID(thingUID, channelId);
builder = builder.withChannel(ChannelBuilder.create(channelUID, channelAcceptedType).build());
@@ -199,11 +198,7 @@ public class ModbusDataHandlerTest extends AbstractModbusOSGiTest {
// Create item of correct type and link it to channel
String itemName = getItemName(channelUID);
final GenericItem item;
if (channelId.startsWith("last") || channelId.equals("datetime")) {
item = new DateTimeItem(itemName);
} else {
item = coreItemFactory.createItem(StringUtils.capitalize(channelId), itemName);
}
item = coreItemFactory.createItem(channelAcceptedType, itemName);
assertThat(String.format("Could not determine correct item type for %s", channelId), item,
is(notNullValue()));
assertNotNull(item);