### Question:
AssignContactController extends AbstractController implements Initializable { ToggleButton getButtonForIdentity(Identity identity) { return buttonByIdentity.get(identity); }  @Override void initialize(URL location, ResourceBundle resources); @FXML
    public ImageView keyIcon; @FXML
    public Label keyLabel; }### Answer:
@Test public void addsAssignment() throws Exception { initController(); ToggleButton button = controller.getButtonForIdentity(unassignedIdentity); button.fire(); assertThat(getAssignedIdentities(), containsInAnyOrder(assignedIdentity, unassignedIdentity)); assertThat(button.isSelected(), is(true)); }
@Test public void unacceptedContactsShowSelected() throws Exception { contact.setStatus(Contact.ContactStatus.UNKNOWN); initController(); ToggleButton assignedButton = controller.getButtonForIdentity(assignedIdentity); assertThat(assignedButton.isSelected(), is(true)); assertThat(getAssignedIdentities(), hasItem(assignedIdentity)); }
@Test public void unknownContactGetsAssignedToBothIdentities() throws Exception { contact.setStatus(Contact.ContactStatus.UNKNOWN); initController(); controller.getButtonForIdentity(unassignedIdentity).fire(); assertThat(getAssignedIdentities(), containsInAnyOrder(unassignedIdentity, assignedIdentity)); }
@Test public void acceptsContact() throws Exception { contact.setStatus(Contact.ContactStatus.UNKNOWN); contactRepository.delete(contact, assignedIdentity); initController(); controller.getButtonForIdentity(assignedIdentity).fire(); assertThat(contact.getStatus(), equalTo(Contact.ContactStatus.NORMAL)); }
@Test public void removesAssignment() throws Exception { initController(); ToggleButton button = controller.getButtonForIdentity(assignedIdentity); button.fire(); assertThat(getAssignedIdentities(), not(hasItem(assignedIdentity))); assertThat(button.isSelected(), is(false)); }