use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class FreeIpaClientExceptionUtilV1Test method testIgnoreNotFoundWithValueWithNotFound.
@Test
public void testIgnoreNotFoundWithValueWithNotFound() throws FreeIpaClientException {
Optional<Object> result = FreeIpaClientExceptionUtil.ignoreNotFoundExceptionWithValue(() -> {
throw new FreeIpaClientException("Not found", new JsonRpcClientException(FreeIpaErrorCodes.NOT_FOUND.getValue(), "Not found", null));
}, null);
assertTrue(result.isEmpty());
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class GroupAddMemberOperationTest 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)));
GroupAddMemberOperation.create(GROUP_NAME, USERS, warnings::put).invoke(freeIpaClient);
verify(freeIpaClient).invoke(eq("group_add_member"), anyList(), any(), any());
assertEquals(1, warnings.size());
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class GroupAddOperationTest method testInvokeIfOtherErrorOccurs.
@Test
public void testInvokeIfOtherErrorOccurs() throws FreeIpaClientException {
Map warnings = Maps.newHashMap();
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenThrow(new FreeIpaClientException("error", new JsonRpcClientException(5000, "", null)));
GroupAddOperation.create(GROUP_NAME, POSIX, warnings::put).invoke(freeIpaClient);
verify(freeIpaClient).invoke(eq("group_add"), anyList(), any(), any());
assertEquals(1, warnings.size());
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class GroupRemoveOperationTest method testInvokeIfOtherErrorOccurs.
@Test
public void testInvokeIfOtherErrorOccurs() throws FreeIpaClientException {
Map warnings = Maps.newHashMap();
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenThrow(new FreeIpaClientException("error", new JsonRpcClientException(5000, "", null)));
GroupRemoveOperation.create(GROUP_NAME, warnings::put).invoke(freeIpaClient);
verify(freeIpaClient).invoke(eq("group_del"), anyList(), any(), any());
assertEquals(1, warnings.size());
}
use of com.googlecode.jsonrpc4j.JsonRpcClientException in project cloudbreak by hortonworks.
the class UserSyncOperationsTest method testSingleErrorHandlingAcceptableErrorCode.
@Test
public void testSingleErrorHandlingAcceptableErrorCode() throws FreeIpaClientException, TimeoutException {
Multimap<String, String> warnings = ArrayListMultimap.create();
Set<String> users = Set.of("user1", "user2");
ArgumentCaptor<List<Object>> flagsCaptor = ArgumentCaptor.forClass(List.class);
ArgumentCaptor<Map<String, Object>> paramsCaptor = ArgumentCaptor.forClass(Map.class);
when(freeIpaClient.invoke(eq("user_enable"), flagsCaptor.capture(), paramsCaptor.capture(), eq(Object.class))).thenThrow(new FreeIpaClientException("Asdf", new JsonRpcClientException(FreeIpaErrorCodes.ALREADY_ACTIVE.getValue(), "fdsa", null)));
underTest.enableUsers(false, freeIpaClient, users, warnings::put);
assertTrue(warnings.isEmpty());
verifyNoInteractions(batchPartitionSizeProperties);
verify(freeIpaClient, never()).callBatch(any(), any(), any(), any(), any());
List<List<Object>> flagsList = flagsCaptor.getAllValues();
assertThat(flagsList, allOf(hasItem(hasItem("user1")), hasItem(hasItem("user2"))));
List<Map<String, Object>> paramsList = paramsCaptor.getAllValues();
assertThat(paramsList, everyItem(aMapWithSize(0)));
verify(interruptChecker, times(4)).throwTimeoutExIfInterrupted();
}
Aggregations