@Test
  public void shouldSendOwnershipUpdateXmlForAddUserOwnershipRequest() throws Exception {
    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 userId = "userId";

    ArgumentCaptor<CaseOwnershipInformation> captor =
        ArgumentCaptor.forClass(CaseOwnershipInformation.class);
    spyCommcareGateway.addUserOwnership(caseOwnershipInformation, userId);

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

    assertThat(captor.getValue().getOwnerId(), is(currentOwnerId + "," + userId));
  }
  @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()));
  }