/** * Create a {@code Thing} with the counter {@code Feature}. Blocks until Thing has been created. * * @return a handle for the counter. */ public FeatureHandle createThingWithCounter() { final Thing thing = Thing.newBuilder() // .setId(thingId) // .setFeature(Feature.newBuilder() // .properties(JsonObject.newBuilder() // .set(COUNTER_VALUE, 0) // .build()) // .withId(COUNTER) // .build()) // .build(); FeatureHandle featureHandle = null; try { featureHandle = twin.create(thing) // .thenApply(created -> twin.forFeature(thingId, COUNTER)) // .get(TIMEOUT, TimeUnit.SECONDS); LOGGER.info("Thing with ID '{}' created.", thingId); } catch (InterruptedException | ExecutionException | TimeoutException e) { LOGGER.error(e.getMessage()); } return featureHandle; }
mappers.put(FeatureDeleted.class, (te, tb) -> tb.build()); mappers.put(FeaturePropertiesCreated.class, (te, tb) -> tb.setFeature(Feature.newBuilder() .properties(((FeaturePropertiesCreated) te).getProperties()) .withId(((FeaturePropertiesCreated) te).getFeatureId()) .build()).build()); mappers.put(FeaturePropertiesModified.class, (te, tb) -> tb.setFeature(Feature.newBuilder() .properties(((FeaturePropertiesModified) te).getProperties()) .withId(((FeaturePropertiesModified) te).getFeatureId())