Move thing unit tests (#1074)

* Move thing unit tests

Moves the thing unit tests from the itests project to the bundle project.

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2019-10-03 19:52:40 +02:00 committed by Christoph Weitkamp
parent 7926b2280e
commit f53beab04c
22 changed files with 28 additions and 18 deletions

View File

@ -24,6 +24,12 @@
<artifactId>org.openhab.core.io.console</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -37,40 +37,40 @@ public class ThingStatusInfoBuilderTest {
@Test
public void testThingStatusInfoBuilderStatus() {
ThingStatusInfo thigStatusInfo = builder.build();
ThingStatusInfo thingStatusInfo = builder.build();
assertThat(thigStatusInfo.getStatus(), is(ThingStatus.ONLINE));
assertThat(thigStatusInfo.getStatusDetail(), is(ThingStatusDetail.NONE));
assertThat(thigStatusInfo.getDescription(), is(nullValue()));
assertThat(thingStatusInfo.getStatus(), is(ThingStatus.ONLINE));
assertThat(thingStatusInfo.getStatusDetail(), is(ThingStatusDetail.NONE));
assertThat(thingStatusInfo.getDescription(), is(nullValue()));
}
@Test
public void testThingStatusInfoBuilderStatusDetails() {
ThingStatusInfo thigStatusInfo = builder.withStatusDetail(ThingStatusDetail.DISABLED).build();
ThingStatusInfo thingStatusInfo = builder.withStatusDetail(ThingStatusDetail.DISABLED).build();
assertThat(thigStatusInfo.getStatus(), is(ThingStatus.ONLINE));
assertThat(thigStatusInfo.getStatusDetail(), is(ThingStatusDetail.DISABLED));
assertThat(thigStatusInfo.getDescription(), is(nullValue()));
assertThat(thingStatusInfo.getStatus(), is(ThingStatus.ONLINE));
assertThat(thingStatusInfo.getStatusDetail(), is(ThingStatusDetail.DISABLED));
assertThat(thingStatusInfo.getDescription(), is(nullValue()));
}
@Test
public void testThingStatusInfoBuilderStatusDescription() {
ThingStatusInfo thigStatusInfo = builder.withDescription("My test description").build();
ThingStatusInfo thingStatusInfo = builder.withDescription("My test description").build();
assertThat(thigStatusInfo.getStatus(), is(ThingStatus.ONLINE));
assertThat(thigStatusInfo.getStatusDetail(), is(ThingStatusDetail.NONE));
assertThat(thigStatusInfo.getDescription(), is("My test description"));
assertThat(thingStatusInfo.getStatus(), is(ThingStatus.ONLINE));
assertThat(thingStatusInfo.getStatusDetail(), is(ThingStatusDetail.NONE));
assertThat(thingStatusInfo.getDescription(), is("My test description"));
}
@Test
public void subsequentBuildsCreateIndependentThingStatusInfos() {
ThingStatusInfo thigStatusInfo1 = builder.build();
ThingStatusInfo thigStatusInfo2 = builder.withStatusDetail(ThingStatusDetail.DISABLED)
ThingStatusInfo thingStatusInfo1 = builder.build();
ThingStatusInfo thingStatusInfo2 = builder.withStatusDetail(ThingStatusDetail.DISABLED)
.withDescription("My test description").build();
assertThat(thigStatusInfo2.getStatus(), is(thigStatusInfo1.getStatus()));
assertThat(thigStatusInfo2.getStatusDetail(), is(not(thigStatusInfo1.getStatusDetail())));
assertThat(thigStatusInfo2.getDescription(), is(not(thigStatusInfo1.getDescription())));
assertThat(thingStatusInfo2.getStatus(), is(thingStatusInfo1.getStatus()));
assertThat(thingStatusInfo2.getStatusDetail(), is(not(thingStatusInfo1.getStatusDetail())));
assertThat(thingStatusInfo2.getDescription(), is(not(thingStatusInfo1.getDescription())));
}
}

View File

@ -12,7 +12,6 @@
*/
package org.eclipse.smarthome.core.thing.internal.firmware;
import static org.eclipse.smarthome.core.thing.firmware.Constants.*;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any;
@ -52,6 +51,11 @@ import org.osgi.framework.Bundle;
*/
public final class ProgressCallbackTest {
private static final String BINDING_ID = "simpleBinding";
private static final String THING_TYPE_ID1 = "simpleThingType1";
private static final ThingTypeUID THING_TYPE_UID1 = new ThingTypeUID(BINDING_ID, THING_TYPE_ID1);
private static final String THING1_ID = "simpleThing1";
private ProgressCallbackImpl sut;
private List<Event> postedEvents;
private ThingUID expectedThingUID;