CheramiClientImpl implements CheramiClient { @Override public ConsumerGroupDescription createConsumerGroup(CreateConsumerGroupRequest request) throws EntityAlreadyExistsError, BadRequestError, IOException { this.throwOnNullRequest(request); if (!request.isSetConsumerGroupName()) { throw new BadRequestError("request missing consumerGroupName parameter"); } if (!request.isSetDestinationPath()) { throw new BadRequestError("request missing destinationPath parameter"); } ThriftRequest<createConsumerGroup_args> thriftRequest = null; ThriftResponse<createConsumerGroup_result> thriftResponse = null; try { thriftRequest = buildThriftRequest("createConsumerGroup", new createConsumerGroup_args(request)); thriftResponse = doRemoteCall(thriftRequest); createConsumerGroup_result result = thriftResponse.getBody(createConsumerGroup_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("createConsumerGroup 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 testCreateConsumerGroup() throws Exception { CreateConsumerGroupRequest request = new CreateConsumerGroupRequest(); final String destination = "/foo/bar"; final String consumerGroup = "/test/group"; final int lockTimeout = new Random().nextInt(); final int maxDelivery = new Random().nextInt(); final String email = "foo@bar.com"; final int skipOlder = new Random().nextInt(); final long timestamp = new Date().getTime(); request.setDestinationPath(destination); request.setConsumerGroupName(consumerGroup); request.setLockTimeoutInSeconds(lockTimeout); request.setMaxDeliveryCount(maxDelivery); request.setOwnerEmail(email); request.setSkipOlderMessagesInSeconds(skipOlder); request.setStartFrom(timestamp); ConsumerGroupDescription response = client.createConsumerGroup(request); assert (response.getDestinationPath().equals(destination)); assert (response.getConsumerGroupName().equals(consumerGroup)); thrown.expect(EntityAlreadyExistsError.class); client.createConsumerGroup(request); }