use of keywhiz.client.KeywhizClient.NotFoundException in project keywhiz by square.
the class AddActionTest method addCallsAddForGroup.
@Test
public void addCallsAddForGroup() throws Exception {
addActionConfig.addType = Arrays.asList("group");
addActionConfig.name = group.getName();
when(keywhizClient.getGroupByName(group.getName())).thenThrow(new NotFoundException());
addAction.run();
verify(keywhizClient).createGroup(addActionConfig.name, "", ImmutableMap.of());
}
use of keywhiz.client.KeywhizClient.NotFoundException in project keywhiz by square.
the class AssignActionTest method assignClientAddsClientsThatDoNotExist.
@Test
public void assignClientAddsClientsThatDoNotExist() throws Exception {
assignActionConfig.assignType = Arrays.asList("client");
assignActionConfig.name = "non-existent-client-name";
assignActionConfig.group = group.getName();
Client client = new Client(543, assignActionConfig.name, null, null, null, null, null, null, false, false);
// Group exists
when(keywhizClient.getGroupByName(group.getName())).thenReturn(group);
// Client does not exist, but 2nd call returns the created client.
when(keywhizClient.getClientByName(client.getName())).thenThrow(new NotFoundException()).thenReturn(client);
// Client not assigned to group
when(keywhizClient.groupDetailsForId(group.getId())).thenReturn(groupDetailResponse);
assignAction.run();
verify(keywhizClient).createClient(assignActionConfig.name);
verify(keywhizClient).enrollClientInGroupByIds(client.getId(), group.getId());
}
use of keywhiz.client.KeywhizClient.NotFoundException in project keywhiz by square.
the class DeleteActionTest method deleteThrowsIfDeleteClientFails.
@Test(expected = AssertionError.class)
public void deleteThrowsIfDeleteClientFails() throws Exception {
deleteActionConfig.deleteType = Arrays.asList("client");
deleteActionConfig.name = "nonexistent-client-name";
when(keywhizClient.getClientByName(deleteActionConfig.name)).thenThrow(new NotFoundException());
deleteAction.run();
}
Aggregations