CheramiClientImpl implements CheramiClient { @Override public DestinationDescription createDestination(CreateDestinationRequest request) throws EntityAlreadyExistsError, BadRequestError, IOException { this.throwOnNullRequest(request); if (!request.isSetPath()) { throw new BadRequestError("request missing 'path' parameter"); } ThriftRequest<createDestination_args> thriftRequest = null; ThriftResponse<createDestination_result> thriftResponse = null; try { thriftRequest = buildThriftRequest("createDestination", new createDestination_args(request)); thriftResponse = doRemoteCall(thriftRequest); createDestination_result result = thriftResponse.getBody(createDestination_result.class); if (thriftResponse.getResponseCode() == ResponseCode.OK) { return result.getSuccess(); } if (result != null && result.isSetEntityExistsError()) { throw result.getEntityExistsError(); } if (result != null && result.isSetRequestError()) { throw result.getRequestError(); } throw new IOException("createDestination failed with unknown error:" + result); } finally { if (thriftResponse != null) { thriftResponse.release(); } } } private  CheramiClientImpl(ClientOptions options); protected  CheramiClientImpl(String host, int port, ClientOptions options); protected  CheramiClientImpl(String routerFile, ClientOptions options); @Override ClientOptions getOptions(); @Override void close(); @Override ConsumerGroupDescription createConsumerGroup(CreateConsumerGroupRequest request); @Override DestinationDescription createDestination(CreateDestinationRequest request); @Override CheramiPublisher createPublisher(CreatePublisherRequest request); @Override CheramiConsumer createConsumer(CreateConsumerRequest request); @Override void deleteConsumerGroup(DeleteConsumerGroupRequest request); @Override void deleteDestination(DeleteDestinationRequest request); @Override ConsumerGroupDescription readConsumerGroup(ReadConsumerGroupRequest request); @Override DestinationDescription readDestination(ReadDestinationRequest request); @Override ConsumerGroupDescription updateConsumerGroup(UpdateConsumerGroupRequest request); @Override DestinationDescription updateDestination(UpdateDestinationRequest request); @Override ListConsumerGroupResult listConsumerGroups(ListConsumerGroupRequest request); @Override ListDestinationsResult listDestinations(ListDestinationsRequest request); @Override List<HostAddress> readDestinationHosts(String path); @Override ReadPublisherOptionsResult readPublisherOptions(String path); @Override ReadConsumerGroupHostsResult readConsumerGroupHosts(String path, String consumerGroupName);  }
@Test public void testCreateDestination() throws Exception { CreateDestinationRequest request = new CreateDestinationRequest(); final String destination = "/foo/bar"; final String email = "foo@bar.com"; final int consumedRetention = new Random().nextInt(); final int unconsumedRetention = new Random().nextInt(); request.setPath(destination); request.setOwnerEmail(email); request.setType(DestinationType.PLAIN); request.setConsumedMessagesRetention(consumedRetention); request.setUnconsumedMessagesRetention(unconsumedRetention); DestinationDescription response = client.createDestination(request); assert (response.getPath().equals(destination)); assert (response.getOwnerEmail().equals(email)); thrown.expect(EntityAlreadyExistsError.class); client.createDestination(request); }