### Question:
CoapProtocolServer implements ProtocolServer { @Override public CompletableFuture<Void> expose(ExposedThing thing) { if (server == null) { return failedFuture(new ProtocolServerException("Unable to expose thing before CoapServer has been started")); } log.info("CoapServer on '{}' port '{}' exposes '{}' at coap: thing.getId(), bindHost, actualPort, thing.getId()); things.put(thing.getId(), thing); CoapResource thingResource = new ThingResource(thing); resources.put(thing.getId(), thingResource); Resource root = server.getRoot(); if (root == null) { return failedFuture(new Exception("Unable to expose thing before CoapServer has been started")); } root.add(thingResource); exposeProperties(thing, thingResource, actualAddresses, ContentManager.getOfferedMediaTypes()); exposeActions(thing, thingResource, actualAddresses, ContentManager.getOfferedMediaTypes()); exposeEvents(thing, thingResource, actualAddresses, ContentManager.getOfferedMediaTypes()); return completedFuture(null); } CoapProtocolServer(Config config); @SuppressWarnings({ "java:S107" })  CoapProtocolServer(String bindHost,
                       int bindPort,
                       List<String> addresses,
                       Map<String, ExposedThing> things,
                       Map<String, CoapResource> resources,
                       Supplier<WotCoapServer> serverSupplier,
                       WotCoapServer server,
                       int actualPort,
                       List<String> actualAddresses); @Override String toString(); @Override CompletableFuture<Void> start(Servient servient); @Override CompletableFuture<Void> stop(); @Override CompletableFuture<Void> expose(ExposedThing thing); @Override CompletableFuture<Void> destroy(ExposedThing thing); @Override URI getDirectoryUrl(); @Override URI getThingUrl(String id); int getBindPort(); Map<String, ExposedThing> getThings();  }### Answer:
@Test public void exposeShouldCreateThingResource() { when(thing.getId()).thenReturn("counter"); CoapProtocolServer server = new CoapProtocolServer(bindHost, bindPort, addresses, things, resources, serverSupplier, coapServer, bindPort, addresses); server.expose(thing); verify(resources, timeout(1 * 1000L)).put(eq("counter"), any(ThingResource.class)); }
@Test public void exposeShouldAddFormsToThing() { when(coapServer.getRoot()).thenReturn(resource); when(thing.getId()).thenReturn("counter"); when(thing.getProperties()).thenReturn(Map.of("count", property)); when(property.isObservable()).thenReturn(true); when(property.observer()).thenReturn(PublishSubject.create()); when(thing.getActions()).thenReturn(Map.of("reset", action)); when(thing.getEvents()).thenReturn(Map.of("changed", event)); when(event.observer()).thenReturn(PublishSubject.create()); CoapProtocolServer server = new CoapProtocolServer(bindHost, bindPort, List.of("coap: server.expose(thing); verify(property, timeout(1 * 1000L).times(2)).addForm(any()); verify(action, timeout(1 * 1000L)).addForm(any()); verify(event, timeout(1 * 1000L)).addForm(any()); }