@Test
public void modifyFeaturePropertiesSoThatThingGetsTooLarge() {

    final CommandStrategy.Context<ThingId> context = getDefaultContext();
    final Feature feature = Feature.newBuilder()
            .properties(JsonObject.newBuilder().set("foo", false).set("bar", 42).build())
            .withId("myFeature")
            .build();
    final long staticOverhead = 80;
    final StringBuilder sb = new StringBuilder();
    for (int i = 0; i < THING_SIZE_LIMIT_BYTES - staticOverhead; i++) {
        sb.append('a');
    }
    final JsonObject largeAttributes = JsonObject.newBuilder()
            .set("a", sb.toString())
            .build();
    final ThingId thingId = ThingId.of("foo","bar");
    final Thing thing = Thing.newBuilder()
            .setId(thingId)
            .setAttributes(largeAttributes)
            .build();
    // creating the Thing should be possible as we are below the limit:
    CreateThing.of(thing, null, DittoHeaders.empty());
    final ModifyFeatureProperties command =
            ModifyFeatureProperties.of(thingId, feature.getId(), feature.getProperties().get(),
                    DittoHeaders.empty());
    // but modifying the feature properties which would cause the Thing to exceed the limit should not be allowed:
    assertThatThrownBy(() -> underTest.doApply(context, thing, NEXT_REVISION, command, null))
            .isInstanceOf(ThingTooLargeException.class);
}