### Question:
DataTypeConstraint { public void init(final DataTypeListItem listItem) { this.listItem = listItem; this.constraintValue = listItem.getDataType().getConstraint(); this.constraintType = listItem.getDataType().getConstraintType(); refreshView(); } @Inject  DataTypeConstraint(final View view,
                              final ManagedInstance<DataTypeConstraintModal> constraintModalManagedInstance); void init(final DataTypeListItem listItem); String getValue(); ConstraintType getConstraintType(); HTMLElement getElement(); void enableEditMode(); void disableEditMode(); void refreshView(); void disable(); void enable();  }### Answer:
@Test public void testInit() { final DataTypeListItem expectedListItem = mock(DataTypeListItem.class); final DataType datatype = mock(DataType.class); final String expectedConstraint = "constraint"; final ConstraintType expectedType = mock(ConstraintType.class); when(expectedListItem.getDataType()).thenReturn(datatype); when(datatype.getConstraint()).thenReturn(expectedConstraint); when(datatype.getConstraintType()).thenReturn(expectedType); dataTypeConstraint.init(expectedListItem); final DataTypeListItem actualListItem = dataTypeConstraint.getListItem(); final String actualConstraint = dataTypeConstraint.getValue(); final ConstraintType actualType = dataTypeConstraint.getConstraintType(); assertEquals(expectedType, actualType); assertEquals(expectedListItem, actualListItem); assertEquals(expectedConstraint, actualConstraint); verify(dataTypeConstraint).refreshView(); }