@Test
  public void findStudyDefinition() throws IllegalStateException, IOException {
    InputStream studyDefinitionStream =
        new ByteArrayInputStream(STUDYDEFINITION_RESPONSE.getBytes(Charset.forName("UTF-8")));
    HttpEntity studyDefinitionEntity =
        when(mock(HttpEntity.class).getContent()).thenReturn(studyDefinitionStream).getMock();
    HttpResponse studyDefinitionResponse =
        when(mock(HttpResponse.class).getEntity()).thenReturn(studyDefinitionEntity).getMock();
    StatusLine statusLine = when(mock(StatusLine.class).getStatusCode()).thenReturn(200).getMock();
    when(studyDefinitionResponse.getStatusLine()).thenReturn(statusLine);

    when(httpClient.execute(
            argThat(
                new BaseMatcher<HttpGet>() {
                  @Override
                  public boolean matches(Object item) {
                    return ((HttpGet) item)
                        .getURI()
                        .toString()
                        .equals(resourceManagerUrl + "/studydefinition/1");
                  }

                  @Override
                  public void describeTo(Description description) {
                    throw new UnsupportedOperationException();
                  }
                })))
        .thenReturn(studyDefinitionResponse);

    GenericLayerResourceManagerService resourceManagerService =
        new GenericLayerResourceManagerService(
            httpClient, resourceManagerUrl, genericLayerDataBinder);
    assertNotNull(resourceManagerService.findStudyDefinition("1"));
  }
  @Test
  public void findCatalogs() throws IllegalStateException, IOException {
    InputStream catalogReleaseStream =
        new ByteArrayInputStream(CATALOG_RELEASE_RESPONSE.getBytes(Charset.forName("UTF-8")));
    HttpEntity catalogReleaseEntity =
        when(mock(HttpEntity.class).getContent()).thenReturn(catalogReleaseStream).getMock();
    HttpResponse catalogReleaseResponse =
        when(mock(HttpResponse.class).getEntity()).thenReturn(catalogReleaseEntity).getMock();
    StatusLine statusLine = when(mock(StatusLine.class).getStatusCode()).thenReturn(200).getMock();
    when(catalogReleaseResponse.getStatusLine()).thenReturn(statusLine);

    when(httpClient.execute(
            argThat(
                new BaseMatcher<HttpGet>() {
                  @Override
                  public boolean matches(Object item) {
                    return ((HttpGet) item)
                        .getURI()
                        .toString()
                        .equals(resourceManagerUrl + "/catalogrelease");
                  }

                  @Override
                  public void describeTo(Description description) {
                    throw new UnsupportedOperationException();
                  }
                })))
        .thenReturn(catalogReleaseResponse);

    GenericLayerResourceManagerService resourceManagerService =
        new GenericLayerResourceManagerService(
            httpClient, resourceManagerUrl, genericLayerDataBinder);
    List<CatalogMeta> catalogs = resourceManagerService.findCatalogs();
    assertEquals(catalogs.size(), 1);
    assertEquals(catalogs.get(0).getId(), "1");
    assertEquals(catalogs.get(0).getName(), "[Catalog Release 1]");
  }