@Test
  public void shouldParseAllLocationsByName() throws HttpException, IOException {
    List<MRSFacility> expected = buildExpectedFacilityList();

    String json = TestUtils.parseJsonFileAsString("json/location-list-response.json");
    when(client.getJson(any(URI.class))).thenReturn(json);

    List<MRSFacility> mrsFacilities = impl.getFacilities("Test");

    assertEquals(expected, mrsFacilities);
  }
  @Test
  public void shouldParseSingleLocation() throws IOException, HttpException {
    MRSFacility expected = makeFacility(true);

    String json = TestUtils.parseJsonFileAsString("json/location-response.json");

    when(client.getJson(null)).thenReturn(json);

    MRSFacility result = impl.getFacility("Test");

    assertEquals(expected, result);
  }
  @Test
  public void shouldNotIncludeUuidOnCreate() throws IOException, HttpException {
    String emptyObject = "{}";

    when(client.postForJson(any(URI.class), any(String.class))).thenReturn(emptyObject);

    impl.saveFacility(makeFacility(true));

    ArgumentCaptor<String> sentJson = ArgumentCaptor.forClass(String.class);
    verify(client).postForJson(any(URI.class), sentJson.capture());

    Location location = (Location) JsonUtils.readJson(sentJson.getValue(), Location.class);

    assertNull(location.getUuid());
  }
  @Test
  public void shouldSendCorrectLocationJson() throws HttpException, IOException {
    String emptyObject = "{}";

    when(client.postForJson(any(URI.class), any(String.class))).thenReturn(emptyObject);

    impl.saveFacility(makeFacility(false));

    JsonElement expected = TestUtils.parseJsonFile("json/location-create.json");
    ArgumentCaptor<String> sentJson = ArgumentCaptor.forClass(String.class);
    verify(client).postForJson(any(URI.class), sentJson.capture());

    JsonElement sent = TestUtils.parseJsonString(sentJson.getValue());

    assertEquals(expected, sent);
  }