Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Replaced constant 'SERIAL_NUMBER' by 'Thing.PROPERTY_SERIAL_NUMBER' (#…
Browse files Browse the repository at this point in the history
…5950)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
  • Loading branch information
cweitkamp authored and maggu2810 committed Jul 23, 2018
1 parent 23fc49b commit 13dd2a0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 19 deletions.
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.smarthome.binding.hue.handler;

import static org.eclipse.smarthome.binding.hue.HueBindingConstants.*;
import static org.eclipse.smarthome.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.*;

Expand Down Expand Up @@ -68,7 +69,7 @@ public void setUp() {
public void assertThatANewUserIsAddedToConfigIfNotExistingYet() {
Configuration configuration = new Configuration();
configuration.put(HOST, DUMMY_HOST);
configuration.put(SERIAL_NUMBER, "testSerialNumber");
configuration.put(PROPERTY_SERIAL_NUMBER, "testSerialNumber");
Bridge bridge = createBridgeThing(configuration);

HueBridgeHandler hueBridgeHandler = getThingHandler(bridge, HueBridgeHandler.class);
Expand All @@ -91,7 +92,7 @@ public void assertThatAnExistingUserIsUsedIfAuthenticationWasSuccessful() {
Configuration configuration = new Configuration();
configuration.put(HOST, DUMMY_HOST);
configuration.put(USER_NAME, TEST_USER_NAME);
configuration.put(SERIAL_NUMBER, "testSerialNumber");
configuration.put(PROPERTY_SERIAL_NUMBER, "testSerialNumber");
Bridge bridge = createBridgeThing(configuration);

HueBridgeHandler hueBridgeHandler = getThingHandler(bridge, HueBridgeHandler.class);
Expand All @@ -113,7 +114,7 @@ public void assertCorrectStatusIfAuthenticationFailedForOldUser() {
Configuration configuration = new Configuration();
configuration.put(HOST, DUMMY_HOST);
configuration.put(USER_NAME, "notAuthenticatedUser");
configuration.put(SERIAL_NUMBER, "testSerialNumber");
configuration.put(PROPERTY_SERIAL_NUMBER, "testSerialNumber");
Bridge bridge = createBridgeThing(configuration);

HueBridgeHandler hueBridgeHandler = getThingHandler(bridge, HueBridgeHandler.class);
Expand All @@ -137,7 +138,7 @@ public void authenticate(String userName) throws IOException, ApiException {
public void verifyStatusIfLinkButtonIsNotPressed() {
Configuration configuration = new Configuration();
configuration.put(HOST, DUMMY_HOST);
configuration.put(SERIAL_NUMBER, "testSerialNumber");
configuration.put(PROPERTY_SERIAL_NUMBER, "testSerialNumber");
Bridge bridge = createBridgeThing(configuration);

HueBridgeHandler hueBridgeHandler = getThingHandler(bridge, HueBridgeHandler.class);
Expand All @@ -161,7 +162,7 @@ public String link(String deviceType) throws IOException, ApiException {
public void verifyStatusIfNewUserCannotBeCreated() {
Configuration configuration = new Configuration();
configuration.put(HOST, DUMMY_HOST);
configuration.put(SERIAL_NUMBER, "testSerialNumber");
configuration.put(PROPERTY_SERIAL_NUMBER, "testSerialNumber");
Bridge bridge = createBridgeThing(configuration);

HueBridgeHandler hueBridgeHandler = getThingHandler(bridge, HueBridgeHandler.class);
Expand All @@ -185,7 +186,7 @@ public String link(String deviceType) throws IOException, ApiException {
public void verifyOfflineIsSetWithoutBridgeOfflineStatus() {
Configuration configuration = new Configuration();
configuration.put(HOST, DUMMY_HOST);
configuration.put(SERIAL_NUMBER, "testSerialNumber");
configuration.put(PROPERTY_SERIAL_NUMBER, "testSerialNumber");
Bridge bridge = createBridgeThing(configuration);

HueBridgeHandler hueBridgeHandler = getThingHandler(bridge, HueBridgeHandler.class);
Expand All @@ -201,7 +202,7 @@ public void verifyOfflineIsSetWithoutBridgeOfflineStatus() {
public void assertThatAStatusConfigurationMessageForMissingBridgeIPIsProperlyReturnedIPIsNull() {
Configuration configuration = new Configuration();
configuration.put(HOST, null);
configuration.put(SERIAL_NUMBER, "testSerialNumber");
configuration.put(PROPERTY_SERIAL_NUMBER, "testSerialNumber");

Bridge bridge = createBridgeThing(configuration);

Expand All @@ -217,7 +218,7 @@ public void assertThatAStatusConfigurationMessageForMissingBridgeIPIsProperlyRet
public void assertThatAStatusConfigurationMessageForMissingBridgeIPIsProperlyReturnedIPIsAnEmptyString() {
Configuration configuration = new Configuration();
configuration.put(HOST, "");
configuration.put(SERIAL_NUMBER, "testSerialNumber");
configuration.put(PROPERTY_SERIAL_NUMBER, "testSerialNumber");

Bridge bridge = createBridgeThing(configuration);

Expand Down
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.smarthome.binding.hue.internal;

import static org.eclipse.smarthome.binding.hue.HueBindingConstants.*;
import static org.eclipse.smarthome.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

Expand Down Expand Up @@ -74,7 +75,7 @@ public void setUp() {
Configuration configuration = new Configuration();
configuration.put(HOST, "1.2.3.4");
configuration.put(USER_NAME, "testUserName");
configuration.put(SERIAL_NUMBER, "testSerialNumber");
configuration.put(PROPERTY_SERIAL_NUMBER, "testSerialNumber");

hueBridge = (Bridge) thingRegistry.createThingOfType(BRIDGE_THING_TYPE_UID, BRIDGE_THING_UID, null, "Bridge",
configuration);
Expand Down
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.smarthome.binding.hue.test;

import static org.eclipse.smarthome.binding.hue.HueBindingConstants.*;
import static org.eclipse.smarthome.core.thing.Thing.PROPERTY_SERIAL_NUMBER;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;

Expand Down Expand Up @@ -101,8 +102,8 @@ public void validDiscoveryResult() {
assertThat(result.getThingTypeUID(), is(THING_TYPE_BRIDGE));
assertThat(result.getBridgeUID(), is(nullValue()));
assertThat(result.getProperties().get(HOST), is("1.2.3.4"));
assertThat(result.getProperties().get(SERIAL_NUMBER), is("serial123"));
assertThat(result.getRepresentationProperty(), is(SERIAL_NUMBER));
assertThat(result.getProperties().get(PROPERTY_SERIAL_NUMBER), is("serial123"));
assertThat(result.getRepresentationProperty(), is(PROPERTY_SERIAL_NUMBER));
}

@Test
Expand Down
Expand Up @@ -53,7 +53,6 @@ public class HueBindingConstants {
// Bridge config properties
public static final String HOST = "ipAddress";
public static final String USER_NAME = "userName";
public static final String SERIAL_NUMBER = "serialNumber";
public static final String POLLING_INTERVAL = "pollingInterval";

// Light config properties
Expand Down
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.smarthome.binding.hue.handler;

import static org.eclipse.smarthome.binding.hue.HueBindingConstants.*;
import static org.eclipse.smarthome.core.thing.Thing.*;

import java.io.IOException;
import java.math.BigDecimal;
Expand Down Expand Up @@ -48,7 +49,6 @@
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.thing.Bridge;
import org.eclipse.smarthome.core.thing.ChannelUID;
import org.eclipse.smarthome.core.thing.Thing;
import org.eclipse.smarthome.core.thing.ThingStatus;
import org.eclipse.smarthome.core.thing.ThingStatusDetail;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
Expand Down Expand Up @@ -299,8 +299,8 @@ private void onConnectionResumed() throws IOException, ApiException {
Config config = fullConfig.getConfig();
if (config != null) {
Map<String, String> properties = editProperties();
properties.put(Thing.PROPERTY_SERIAL_NUMBER, config.getMACAddress().replaceAll(":", "").toLowerCase());
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, config.getSoftwareVersion());
properties.put(PROPERTY_SERIAL_NUMBER, config.getMACAddress().replaceAll(":", "").toLowerCase());
properties.put(PROPERTY_FIRMWARE_VERSION, config.getSoftwareVersion());
updateProperties(properties);
propertiesInitializedSuccessfully = true;
}
Expand Down
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.smarthome.binding.hue.internal.discovery;

import static org.eclipse.smarthome.binding.hue.HueBindingConstants.*;
import static org.eclipse.smarthome.core.thing.Thing.PROPERTY_SERIAL_NUMBER;

import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -53,10 +54,11 @@ public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
if (uid != null) {
Map<String, Object> properties = new HashMap<>(2);
properties.put(HOST, device.getDetails().getBaseURL().getHost());
properties.put(SERIAL_NUMBER, device.getDetails().getSerialNumber());
properties.put(PROPERTY_SERIAL_NUMBER, device.getDetails().getSerialNumber());

DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
.withLabel(device.getDetails().getFriendlyName()).withRepresentationProperty(SERIAL_NUMBER).build();
.withLabel(device.getDetails().getFriendlyName()).withRepresentationProperty(PROPERTY_SERIAL_NUMBER)
.build();
return result;
} else {
return null;
Expand Down
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.smarthome.binding.hue.internal.discovery;

import static org.eclipse.smarthome.binding.hue.HueBindingConstants.*;
import static org.eclipse.smarthome.core.thing.Thing.PROPERTY_SERIAL_NUMBER;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -94,7 +95,8 @@ private void discoverHueBridges() {
ThingUID uid = new ThingUID(THING_TYPE_BRIDGE, serialNumber);
DiscoveryResult result = DiscoveryResultBuilder.create(uid)
.withProperties(buildProperties(host, serialNumber))
.withLabel(LABEL_PATTERN.replace("IP", host)).withRepresentationProperty(SERIAL_NUMBER).build();
.withLabel(LABEL_PATTERN.replace("IP", host)).withRepresentationProperty(PROPERTY_SERIAL_NUMBER)
.build();
thingDiscovered(result);
}
}
Expand All @@ -110,7 +112,7 @@ private void discoverHueBridges() {
private Map<String, Object> buildProperties(String host, String serialNumber) {
Map<String, Object> properties = new HashMap<>(2);
properties.put(HOST, host);
properties.put(SERIAL_NUMBER, serialNumber);
properties.put(PROPERTY_SERIAL_NUMBER, serialNumber);
return properties;
}

Expand Down

0 comments on commit 13dd2a0

Please sign in to comment.