@Test
  public void shouldCreateOwnershipCase() {
    String allUsersGrpId = "grp1";
    Group allUsersGroup = new Group();
    allUsersGroup.setId(allUsersGrpId);
    model.put(CommcareGateway.OWNER_ID_KEY, allUsersGrpId);

    doReturn(allUsersGroup).when(mockAllGroups).getGroupByName(CommcareGateway.ALL_USERS_GROUP);
    doReturn(getExpectedOwnershipCaseXml())
        .when(spyCommcareGateway)
        .getXmlFromObject(OWNERSHIP_CASE_REGISTER_FORM_TEMPLATE_PATH, model);

    spyCommcareGateway.createOwnershipCase();
    verify(mockHttpClientService).post(someUrl, getExpectedOwnershipCaseXml());
  }
  @Test
  public void shouldSubmitUpdateOwnerFormForGroupOwnershipRequest() {
    CaseOwnershipInformation caseOwnershipInformation =
        getCaseOwnershipInformation(
            UUID.randomUUID().toString(), null, "f98589102c60fcc2e0f3c422bb361ebd", "cg1", null);
    String currentOwnerId = caseOwnershipInformation.getUserId();
    model.put(CommcareGateway.CASE_OWNERSHIP_FORM_KEY, caseOwnershipInformation);
    doReturn(getExpectedBeneficiaryCaseXml())
        .when(spyCommcareGateway)
        .getXmlFromObject(eq(OWNER_UPDATE_FORM_TEMPLATE_PATH), eq(model));
    String someGroup = "someGroup";
    Group group = new Group();
    group.setId("somegroupId");
    doReturn(group).when(mockAllGroups).getGroupByName(someGroup);
    ArgumentCaptor<CaseOwnershipInformation> captor =
        ArgumentCaptor.forClass(CaseOwnershipInformation.class);

    spyCommcareGateway.addGroupOwnership(caseOwnershipInformation, someGroup);

    verify(spyCommcareGateway).postOwnerUpdate(captor.capture());
    verify(mockHttpClientService).post(someUrl, getExpectedBeneficiaryCaseXml());

    assertThat(captor.getValue().getOwnerId(), is(currentOwnerId + "," + group.getId()));
  }