### Question:
DataTypeConstraintView implements DataTypeConstraint.View { @Override public void setText(final String text) { final String constraints = addConstraints(); final String constraintText = isEmpty(text) ? constraints : text; constraintsAnchorText.textContent = constraintText; constraintsLabelText.textContent = constraintText; } @Inject  DataTypeConstraintView(final HTMLAnchorElement constraintsAnchorContainer,
                                  final HTMLDivElement constraintsLabelContainer,
                                  final @Named("span") HTMLElement constraintsAnchorText,
                                  final @Named("span") HTMLElement constraintsLabelText,
                                  final @Named("span") HTMLElement constraintsTooltip,
                                  final TranslationService translationService); @Override void init(final DataTypeConstraint presenter); @PostConstruct void setup(); @EventHandler("constraints-anchor-container") void onConstraintsClick(final ClickEvent e); @Override void showAnchor(); @Override void hideAnchor(); @Override void setText(final String text); @Override void enable(); @Override void disable();  }### Answer:
@Test public void testSetTextWhenTextIsNotBlank() { final String expectedText = "text"; constraintsAnchorText.textContent = "something..."; constraintsLabelText.textContent = "something..."; view.setText(expectedText); assertEquals(expectedText, constraintsAnchorText.textContent); assertEquals(expectedText, constraintsLabelText.textContent); }
@Test public void testSetTextWhenTextIsBlank() { final String expectedText = "Add Constraints"; when(translationService.format(DataTypeConstraintView_AddConstraints)).thenReturn(expectedText); constraintsAnchorText.textContent = "something..."; constraintsLabelText.textContent = "something..."; view.setText(""); assertEquals(expectedText, constraintsAnchorText.textContent); assertEquals(expectedText, constraintsLabelText.textContent); }