use of com.googlecode.jsonrpc4j.JsonRpcClientException 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.googlecode.jsonrpc4j.JsonRpcClientException 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.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class SudoRuleShowOperationTest method testInvokeShouldReturnEmptyInCaseOfNotFoundException.
@Test
public void testInvokeShouldReturnEmptyInCaseOfNotFoundException() throws FreeIpaClientException {
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenThrow(new FreeIpaClientException("", new JsonRpcClientException(FreeIpaErrorCodes.NOT_FOUND.getValue(), null, null)));
Optional<SudoRule> result = SudoRuleShowOperation.create(NAME).invoke(freeIpaClient);
assertEquals(Optional.empty(), result);
verify(freeIpaClient).invoke(eq("sudorule_show"), argThat(argument -> argument.contains(NAME) && argument.size() == 1), argThat(argument -> argument.isEmpty()), eq(SudoRule.class));
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class UserModOperationTest method testInvokeIfOtherErrorOccurs.
@Test
public void testInvokeIfOtherErrorOccurs() throws FreeIpaClientException {
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenThrow(new FreeIpaClientException("error", new JsonRpcClientException(5000, "", null)));
assertThrows(FreeIpaClientException.class, () -> UserModOperation.create("key", new Object(), USER_NAME).invoke(freeIpaClient));
verify(freeIpaClient).invoke(eq("user_mod"), anyList(), any(), any());
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class FreeIpaClientExceptionUtilV1Test method testIsNotFoundException.
@Test
public void testIsNotFoundException() throws Exception {
Assertions.assertFalse(FreeIpaClientExceptionUtil.isNotFoundException(new FreeIpaClientException(MESSAGE)));
Assertions.assertFalse(FreeIpaClientExceptionUtil.isNotFoundException(new FreeIpaClientException(MESSAGE, new JsonRpcClientException(DUPLICATE_ENTRY, MESSAGE, null))));
assertTrue(FreeIpaClientExceptionUtil.isNotFoundException(new FreeIpaClientException(MESSAGE, new JsonRpcClientException(NOT_FOUND, MESSAGE, null))));
}
Aggregations