use of com.sequenceiq.freeipa.client.FreeIpaClientException in project cloudbreak by hortonworks.
the class GroupRemoveMemberOperationTest method testInvokeIfErrorOccurs.
@Test
public void testInvokeIfErrorOccurs() throws FreeIpaClientException {
Map warnings = Maps.newHashMap();
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenThrow(new FreeIpaClientException("error", new JsonRpcClientException(5000, "", null)));
GroupRemoveMemberOperation.create(GROUP_NAME, USERS, warnings::put).invoke(freeIpaClient);
verify(freeIpaClient).invoke(eq("group_remove_member"), anyList(), any(), any());
assertEquals(1, warnings.size());
}
use of com.sequenceiq.freeipa.client.FreeIpaClientException in project cloudbreak by hortonworks.
the class GroupRemoveOperationTest method testInvokeIfNotFoundErrorOccurs.
@Test
public void testInvokeIfNotFoundErrorOccurs() throws FreeIpaClientException {
Map warnings = Maps.newHashMap();
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenThrow(new FreeIpaClientException("error", new JsonRpcClientException(4001, "", null)));
GroupRemoveOperation.create(GROUP_NAME, warnings::put).invoke(freeIpaClient);
verify(freeIpaClient).invoke(eq("group_del"), anyList(), any(), any());
assertEquals(0, warnings.size());
}
use of com.sequenceiq.freeipa.client.FreeIpaClientException in project cloudbreak by hortonworks.
the class SudoRuleAddOperationTest method testInvokeWithAllHostCategory.
@Test
public void testInvokeWithAllHostCategory() throws FreeIpaClientException {
RPCResponse<Object> rpcResponse = new RPCResponse<>();
rpcResponse.setResult(new SudoRule());
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
SudoRuleAddOperation.create(NAME, true, null).invoke(freeIpaClient);
verify(freeIpaClient).invoke(eq("sudorule_add"), argThat(argument -> argument.contains(NAME) && argument.size() == 1), argThat(argument -> "all".equals(argument.get("hostcategory")) && argument.size() == 1), eq(SudoRule.class));
}
use of com.sequenceiq.freeipa.client.FreeIpaClientException in project cloudbreak by hortonworks.
the class SudoRuleAddOperationTest method testInvoke.
@Test
public void testInvoke() throws FreeIpaClientException {
RPCResponse<Object> rpcResponse = new RPCResponse<>();
rpcResponse.setResult(new SudoRule());
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
SudoRuleAddOperation.create(NAME, false, null).invoke(freeIpaClient);
verify(freeIpaClient).invoke(eq("sudorule_add"), argThat(argument -> argument.contains(NAME) && argument.size() == 1), argThat(argument -> argument.isEmpty()), eq(SudoRule.class));
}
use of com.sequenceiq.freeipa.client.FreeIpaClientException in project cloudbreak by hortonworks.
the class SudoRuleShowOperationTest method testInvokeShouldFreeIpaClientException.
@Test
public void testInvokeShouldFreeIpaClientException() throws FreeIpaClientException {
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenThrow(new FreeIpaClientException(null));
assertThrows(FreeIpaClientException.class, () -> SudoRuleShowOperation.create(NAME).invoke(freeIpaClient));
verify(freeIpaClient).invoke(eq("sudorule_show"), argThat(argument -> argument.contains(NAME) && argument.size() == 1), argThat(argument -> argument.isEmpty()), eq(SudoRule.class));
}
Aggregations