@Test(expected = DoesNotExistException.class) public void testGetMappingDoesNotExist() throws DoesNotExistException { Mockito.when(response.getStatus()).thenReturn(404); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Does not exist!")); ma.getMapping("map0"); }
public MetadataTransformation getMapping(String id) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + MappingOptionListContainer.MAPPINGS + "/" + id); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getMapping(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } MetadataTransformation metadataTransformation = response.readEntity(MetadataTransformation.class); LOGGER.info("getMapping(..) success!"); return metadataTransformation; }
MappingsAccessor { public MetadataTransformation getMapping(String id) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + MappingOptionListContainer.MAPPINGS + "/" + id); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getMapping(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } MetadataTransformation metadataTransformation = response.readEntity(MetadataTransformation.class); LOGGER.info("getMapping(..) success!"); return metadataTransformation; } }
MappingsAccessor { public MetadataTransformation getMapping(String id) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + MappingOptionListContainer.MAPPINGS + "/" + id); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getMapping(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } MetadataTransformation metadataTransformation = response.readEntity(MetadataTransformation.class); LOGGER.info("getMapping(..) success!"); return metadataTransformation; } MappingsAccessor(URL restUrl, String username, String password);   MappingsAccessor(URL restUrl, String username, String password, Client client); }
MappingsAccessor { public MetadataTransformation getMapping(String id) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + MappingOptionListContainer.MAPPINGS + "/" + id); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getMapping(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } MetadataTransformation metadataTransformation = response.readEntity(MetadataTransformation.class); LOGGER.info("getMapping(..) success!"); return metadataTransformation; } MappingsAccessor(URL restUrl, String username, String password);   MappingsAccessor(URL restUrl, String username, String password, Client client); MetadataTransformation getMapping(String id); void deleteMapping(String id); void createMapping(MetadataTransformation metadataTransformation, File file); void updateMapping(String id, MetadataTransformation metadataTransformation, File file); }
MappingsAccessor { public MetadataTransformation getMapping(String id) throws DoesNotExistException { WebTarget target = client.target(restUrl + "/" + MappingOptionListContainer.MAPPINGS + "/" + id); Response response = target.request(MediaType.APPLICATION_JSON).get(); if (response.getStatus() == 404) { Result errorMessage = response.readEntity(Result.class); LOGGER.warn("getMapping(..) failure! : " + errorMessage.getResult()); throw new DoesNotExistException(errorMessage.getResult()); } MetadataTransformation metadataTransformation = response.readEntity(MetadataTransformation.class); LOGGER.info("getMapping(..) success!"); return metadataTransformation; } MappingsAccessor(URL restUrl, String username, String password);   MappingsAccessor(URL restUrl, String username, String password, Client client); MetadataTransformation getMapping(String id); void deleteMapping(String id); void createMapping(MetadataTransformation metadataTransformation, File file); void updateMapping(String id, MetadataTransformation metadataTransformation, File file);  }