@Test
  public void shouldCreateGroupIfNotExists() throws Exception {

    String[] newUsers = {"1", "2", "3"};
    String groupName = "All_Users";
    doReturn(null).when(mockAllGroups).getGroupByName(groupName);
    spyCommcareGateway.createOrUpdateGroup(groupName, newUsers);
    ArgumentCaptor<Group> groupCaptor = ArgumentCaptor.forClass(Group.class);
    verify(mockAllGroups).add(groupCaptor.capture());

    assertThat(groupCaptor.getValue().getUsers(), is(newUsers));
    assertThat(groupCaptor.getValue().getName(), is(groupName));
  }
  @Test
  public void shouldUpdateGroupIfExists() throws Exception {

    String[] newUsers = {"1", "2", "3"};
    String groupName = "All_Users";
    Group group = new Group();
    String[] existingUsers = {"4", "5"};
    group.setUsers(existingUsers);
    group.setName(groupName);
    doReturn(group).when(mockAllGroups).getGroupByName(groupName);
    spyCommcareGateway.createOrUpdateGroup(groupName, newUsers);
    ArgumentCaptor<Group> groupCaptor = ArgumentCaptor.forClass(Group.class);
    verify(mockAllGroups).update(groupCaptor.capture());

    assertThat(groupCaptor.getValue().getUsers(), is(ArrayUtils.addAll(existingUsers, newUsers)));
    assertThat(groupCaptor.getValue().getName(), is(groupName));
  }