### Question:
ExposedThingProperty extends ThingProperty<T> { public CompletableFuture<T> read() { if (state.getReadHandler() != null) { log.debug("'{}' calls registered readHandler for Property '{}'", thing.getId(), name); try { return state.getReadHandler().get().whenComplete((customValue, e) -> state.setValue(customValue)); } catch (Exception e) { return failedFuture(e); } } else { CompletableFuture<T> future = new CompletableFuture<>(); T value = state.getValue(); log.debug("'{}' gets internal value '{}' for Property '{}'", thing.getId(), value, name); future.complete(value); return future; } } @SuppressWarnings("squid:S107")  ExposedThingProperty(String name,
                                ExposedThing thing,
                                PropertyState<T> state,
                                String objectType,
                                String description,
                                Map<String, String> descriptions,
                                String type,
                                boolean observable,
                                boolean readOnly,
                                boolean writeOnly,
                                Map<String, Map<String, Object>> uriVariables,
                                Map<String, Object> optionalProperties);  ExposedThingProperty(String name, ThingProperty<T> property, ExposedThing thing); CompletableFuture<T> read(); CompletableFuture<T> write(T value); Observable<Optional<T>> observer(); PropertyState<T> getState(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString();  }### Answer:
@Test public void readWithoutHandlerShouldReturnStateValue() { exposedProperty = new ExposedThingProperty<>(name, thing, state, objectType, description, descriptions, type, observable, readOnly, writeOnly, uriVariables, optionalProperties); exposedProperty.read(); verify(state).getValue(); }
@Test public void readWithHandlerShouldCallHandler() { when(state.getReadHandler()).thenReturn(readHandler); exposedProperty = new ExposedThingProperty<>(name, thing, state, objectType, description, descriptions, type, observable, readOnly, writeOnly, uriVariables, optionalProperties); exposedProperty.read(); verify(readHandler).get(); }
@Test(expected = ExecutionException.class) public void readWithBrokenHandlerShouldReturnFailedFuture() throws ExecutionException, InterruptedException { when(readHandler.get()).thenThrow(new RuntimeException()); when(state.getReadHandler()).thenReturn(readHandler); exposedProperty = new ExposedThingProperty<>(name, thing, state, objectType, description, descriptions, type, observable, readOnly, writeOnly, uriVariables, optionalProperties); exposedProperty.read().get(); }