ThingHandlerHelper { public static boolean isHandlerInitialized(final ThingStatus thingStatus) { return thingStatus == ThingStatus.OFFLINE || thingStatus == ThingStatus.ONLINE || thingStatus == ThingStatus.UNKNOWN; } private  ThingHandlerHelper(); static boolean isHandlerInitialized(final ThingStatus thingStatus); static boolean isHandlerInitialized(final Thing thing); static boolean isHandlerInitialized(final ThingHandler handler);  }
@Test public void assertIsHandlerInitializedWorksCorrectlyForAThingStatus() { assertThat(isHandlerInitialized(ThingStatus.UNINITIALIZED), is(false)); assertThat(isHandlerInitialized(ThingStatus.INITIALIZING), is(false)); assertThat(isHandlerInitialized(ThingStatus.REMOVING), is(false)); assertThat(isHandlerInitialized(ThingStatus.REMOVED), is(false)); assertThat(isHandlerInitialized(ThingStatus.UNKNOWN), is(true)); assertThat(isHandlerInitialized(ThingStatus.ONLINE), is(true)); assertThat(isHandlerInitialized(ThingStatus.OFFLINE), is(true)); }
@Test public void assertIsHandlerInitializedWorksCorrectlyForAThing() { thing.setStatusInfo(create(ThingStatus.UNINITIALIZED).build()); assertThat(isHandlerInitialized(thing), is(false)); thing.setStatusInfo(create(ThingStatus.INITIALIZING).build()); assertThat(isHandlerInitialized(thing), is(false)); thing.setStatusInfo(create(ThingStatus.REMOVING).build()); assertThat(isHandlerInitialized(thing), is(false)); thing.setStatusInfo(create(ThingStatus.REMOVED).build()); assertThat(isHandlerInitialized(thing), is(false)); thing.setStatusInfo(create(ThingStatus.UNKNOWN).build()); assertThat(isHandlerInitialized(thing), is(true)); thing.setStatusInfo(create(ThingStatus.ONLINE).build()); assertThat(isHandlerInitialized(thing), is(true)); thing.setStatusInfo(create(ThingStatus.OFFLINE).build()); assertThat(isHandlerInitialized(thing), is(true)); }
@Test public void assertIsHandlerInitializedWorksCorrectlyForAThingHandler() { when(thingHandler.getThing()).thenReturn(thing); thing.setStatusInfo(create(ThingStatus.UNINITIALIZED).build()); assertThat(isHandlerInitialized(thingHandler), is(false)); thing.setStatusInfo(create(ThingStatus.INITIALIZING).build()); assertThat(isHandlerInitialized(thingHandler), is(false)); thing.setStatusInfo(create(ThingStatus.REMOVING).build()); assertThat(isHandlerInitialized(thingHandler), is(false)); thing.setStatusInfo(create(ThingStatus.REMOVED).build()); assertThat(isHandlerInitialized(thingHandler), is(false)); thing.setStatusInfo(create(ThingStatus.UNKNOWN).build()); assertThat(isHandlerInitialized(thingHandler), is(true)); thing.setStatusInfo(create(ThingStatus.ONLINE).build()); assertThat(isHandlerInitialized(thingHandler), is(true)); thing.setStatusInfo(create(ThingStatus.OFFLINE).build()); assertThat(isHandlerInitialized(thingHandler), is(true)); }