### Question:
TooltipAspectDefinition extends ModelToUiAspectDefinition<String> { @Override public Aspect<String> createAspect() { switch (type) { case AUTO: return StringUtils.isEmpty(value) ? Aspect.of(NAME) : Aspect.of(NAME, value); case STATIC: return Aspect.of(NAME, value); case DYNAMIC: return Aspect.of(NAME); default: throw new IllegalArgumentException("TooltipType " + type + " is not supported."); } } TooltipAspectDefinition(TooltipType type, String value); @Override Aspect<String> createAspect(); @Override Consumer<String> createComponentValueSetter(ComponentWrapper componentWrapper); static final String NAME; }### Answer:
@Test public void testCreateAspect_Default_WithValue() { TooltipAspectDefinition aspectDefinition = new TooltipAspectDefinition(TooltipType.AUTO, "Bar"); Aspect<String> createdAspect = aspectDefinition.createAspect(); assertThat(createdAspect.getName(), is(TooltipAspectDefinition.NAME)); assertThat(createdAspect.isValuePresent(), is(true)); assertThat(createdAspect.getValue(), is("Bar")); }
@Test public void testCreateAspect_Default_WithoutValue() { TooltipAspectDefinition aspectDefinition = new TooltipAspectDefinition(TooltipType.AUTO, ""); Aspect<String> createdAspect = aspectDefinition.createAspect(); assertThat(createdAspect.getName(), is(TooltipAspectDefinition.NAME)); assertThat(createdAspect.isValuePresent(), is(false)); }
@Test public void testCreateAspect_static() { TooltipAspectDefinition aspectDefinition = new TooltipAspectDefinition(TooltipType.STATIC, "Foo"); Aspect<String> createdAspect = aspectDefinition.createAspect(); assertThat(createdAspect.getName(), is(TooltipAspectDefinition.NAME)); assertThat(createdAspect.getValue(), is("Foo")); }
@Test public void testCreateAspect_dynamic() { TooltipAspectDefinition aspectDefinition = new TooltipAspectDefinition(TooltipType.DYNAMIC, "Bar"); Aspect<String> createdAspect = aspectDefinition.createAspect(); assertThat(createdAspect.getName(), is(TooltipAspectDefinition.NAME)); assertThat(createdAspect.isValuePresent(), is(false)); }