Search in sources :

Example 6 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class GroupRemoveOperationTest method testInvoke.

@Test
public void testInvoke() throws FreeIpaClientException {
    Map warnings = Maps.newHashMap();
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    rpcResponse.setResult(new Group());
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    GroupRemoveOperation.create(GROUP_NAME, warnings::put).invoke(freeIpaClient);
    verify(freeIpaClient).invoke(eq("group_del"), anyList(), any(), any());
}
Also used : Group(com.sequenceiq.freeipa.client.model.Group) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 7 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse 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));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Mockito.when(org.mockito.Mockito.when) SudoRule(com.sequenceiq.freeipa.client.model.SudoRule) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) SudoRule(com.sequenceiq.freeipa.client.model.SudoRule) Test(org.junit.jupiter.api.Test)

Example 8 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse 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));
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) ArgumentMatchers.argThat(org.mockito.ArgumentMatchers.argThat) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Mockito.when(org.mockito.Mockito.when) SudoRule(com.sequenceiq.freeipa.client.model.SudoRule) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) SudoRule(com.sequenceiq.freeipa.client.model.SudoRule) Test(org.junit.jupiter.api.Test)

Example 9 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class UserModOperationTest method testInvoke.

@Test
public void testInvoke() throws FreeIpaClientException {
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    rpcResponse.setResult(new User());
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    UserModOperation.create("key", new Object(), USER_NAME).invoke(freeIpaClient);
    verify(freeIpaClient).invoke(eq("user_mod"), anyList(), any(), any());
}
Also used : User(com.sequenceiq.freeipa.client.model.User) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Test(org.junit.jupiter.api.Test)

Example 10 with RPCResponse

use of com.sequenceiq.cloudbreak.client.RPCResponse in project cloudbreak by hortonworks.

the class GroupAddOperationTest method testInvokeNonPosix.

@Test
public void testInvokeNonPosix() throws FreeIpaClientException {
    Map warnings = Maps.newHashMap();
    RPCResponse<Object> rpcResponse = new RPCResponse<>();
    rpcResponse.setResult(new Group());
    when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
    GroupAddOperation.create(GROUP_NAME, NONPOSIX, warnings::put).invoke(freeIpaClient);
    ArgumentCaptor<Map<String, Object>> paramCaptor = ArgumentCaptor.forClass(Map.class);
    verify(freeIpaClient).invoke(eq("group_add"), anyList(), paramCaptor.capture(), any());
    Map<String, Object> params = paramCaptor.getValue();
    assertTrue(params.containsKey("nonposix"));
    assertTrue((Boolean) params.get("nonposix"));
}
Also used : Group(com.sequenceiq.freeipa.client.model.Group) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Aggregations

RPCResponse (com.sequenceiq.cloudbreak.client.RPCResponse)43 Test (org.junit.jupiter.api.Test)31 Map (java.util.Map)17 Group (com.sequenceiq.freeipa.client.model.Group)12 User (com.sequenceiq.freeipa.client.model.User)10 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)9 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)9 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)9 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)9 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)9 Mock (org.mockito.Mock)9 Mockito.verify (org.mockito.Mockito.verify)9 Mockito.when (org.mockito.Mockito.when)9 MockitoExtension (org.mockito.junit.jupiter.MockitoExtension)9 RPCMessage (com.sequenceiq.cloudbreak.client.RPCMessage)8 List (java.util.List)8 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)7 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)7 SudoRule (com.sequenceiq.freeipa.client.model.SudoRule)6 FmsUser (com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser)6