### Question:
AggregatorsAccessor { public void createAggregator(String id, String name, String nameCode, String homepage) throws InvalidArgumentsException, MissingArgumentsException, AlreadyExistsException, InternalServerErrorException { WebTarget target = client.target(restUrl + "/" + AggregatorOptionListContainer.AGGREGATORS); Aggregator aggregator = new Aggregator(id, name, nameCode, homepage, null); Response response = target.request(MediaType.APPLICATION_JSON).post( Entity.entity(aggregator, MediaType.APPLICATION_JSON), Response.class); switch (response.getStatus()) { case 400: Result errorMessage = response.readEntity(Result.class); LOGGER.warn("createAggregator(..) failure! : " + errorMessage.getResult()); throw new InvalidArgumentsException(errorMessage.getResult()); case 406: errorMessage = response.readEntity(Result.class); LOGGER.warn("createAggregator(..) failure! : " + errorMessage.getResult()); throw new MissingArgumentsException(errorMessage.getResult()); case 409: errorMessage = response.readEntity(Result.class); LOGGER.warn("createAggregator(..) failure! : " + errorMessage.getResult()); throw new AlreadyExistsException(errorMessage.getResult()); case 500: errorMessage = response.readEntity(Result.class); LOGGER.warn("createAggregator(..) failure! : " + errorMessage.getResult()); throw new InternalServerErrorException(errorMessage.getResult()); } LOGGER.info("createAggregator(..) success!"); } AggregatorsAccessor(URL restUrl, String username, String password);   AggregatorsAccessor(URL restUrl, String username, String password, Client client); Aggregator getAggregator(String aggregatorId); void deleteAggregator(String aggregatorId); List<Aggregator> getAggregatorList(int offset, int number); void createAggregator(String id, String name, String nameCode, String homepage); void updateAggregator(String id, String newId, String name, String nameCode,
      String homepage); URL getRestUrl(); void setRestUrl(URL restUrl);  }### Answer:
@Test public void testCreateAggregator() throws InternalServerErrorException, InvalidArgumentsException, MissingArgumentsException, AlreadyExistsException { Mockito.when(response.getStatus()).thenReturn(201); aa.createAggregator("Id", "Greece", "GR", "http: }
@Test(expected = InvalidArgumentsException.class) public void testCreateAggregatorInvalidArguments() throws InternalServerErrorException, InvalidArgumentsException, MissingArgumentsException, AlreadyExistsException { Mockito.when(response.getStatus()).thenReturn(400); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Invalid argument!")); aa.createAggregator("Id", "Greece", "GR", "http: }
@Test(expected = MissingArgumentsException.class) public void testCreateAggregatorMissingArguments() throws InternalServerErrorException, InvalidArgumentsException, MissingArgumentsException, AlreadyExistsException { Mockito.when(response.getStatus()).thenReturn(406); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Invalid argument!")); aa.createAggregator("Id", "Greece", "GR", "http: }
@Test(expected = AlreadyExistsException.class) public void testCreateAggregatorAlreadyExists() throws InternalServerErrorException, InvalidArgumentsException, MissingArgumentsException, AlreadyExistsException { Mockito.when(response.getStatus()).thenReturn(409); Mockito.when(response.readEntity(Result.class)).thenReturn(new Result("Already exist!")); aa.createAggregator("Id", "Greece", "GR", "http: }
@Test(expected = InternalServerErrorException.class) public void testCreateAggregatorInternalServerError() throws InternalServerErrorException, InvalidArgumentsException, MissingArgumentsException, AlreadyExistsException { Mockito.when(response.getStatus()).thenReturn(500); Mockito.when(response.readEntity(Result.class)) .thenReturn(new Result("Internal Server Error!")); aa.createAggregator("Id", "Greece", "GR", "http: }