@Test
 public void shouldRegisterFacility() {
   FacilityInformation facilityInformation = spy(new FacilityInformation());
   model.put(FACILITY_FORM_KEY, facilityInformation);
   doReturn(getExpectedFacilityXml())
       .when(spyCommcareGateway)
       .getXmlFromObject(FACILITY_REGISTRATION_FORM_TEMPLATE_PATH, model);
   spyCommcareGateway.registerFacilityUser(facilityInformation);
   verify(mockHttpClientService)
       .post(spyCommcareGateway.getCOMMCARE_RECIEVER_URL(), getExpectedFacilityXml());
 }
 @Test
 public void shouldCreateFacilityCase() {
   FacilityInformation facilityInformation = spy(new FacilityInformation());
   model.put(FACILITY_FORM_KEY, facilityInformation);
   doReturn(getExpectedFacilityCaseXml())
       .when(spyCommcareGateway)
       .getXmlFromObject(FACILITY_CASE_FORM_TEMPLATE_PATH, model);
   spyCommcareGateway.createFacilityCase(facilityInformation);
   verify(mockHttpClientService)
       .post(spyCommcareGateway.getCOMMCARE_RECIEVER_URL(), getExpectedFacilityCaseXml());
 }
  @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));
  }