@Test public void cursorResetApi() throws Exception { try { before(); final NakadiClient client = NakadiClient.newBuilder() .baseURI("http: .build(); server.enqueue(new MockResponse().setResponseCode(204)); final SubscriptionResource subscriptions = client.resources().subscriptions(); final String eventTypeName = "blackhole.sun"; final String subscriptionId = "5-19"; final String partition = "7"; final String cursorToken = "octave4"; final String offset = "000000000019642017"; final Cursor cursor = new Cursor(partition, offset, eventTypeName).cursorToken(cursorToken); subscriptions.reset(subscriptionId, Lists.newArrayList(cursor)); final RecordedRequest request = server.takeRequest(); assertEquals("PATCH /subscriptions/5-19/cursors HTTP/1.1", request.getRequestLine()); assertEquals("application/json; charset=utf8", request.getHeaders().get("Content-Type")); assertEquals(NakadiClient.USER_AGENT, request.getHeaders().get("User-Agent")); final String body = request.getBody().readUtf8(); final SubscriptionResourceReal.CursorResetCollection sent = json.fromJson(body, SubscriptionResourceReal.CursorResetCollection.class); assertEquals(1, sent.items.size()); final Cursor sentCursor = sent.items.get(0); assertEquals("expect cursor token to be filtered out before sending", Optional.empty(), sentCursor.cursorToken()); assertEquals(partition, sentCursor.partition()); assertEquals(offset, sentCursor.offset()); assertEquals(eventTypeName, sentCursor.eventType().get()); } finally { after(); } }
@Override public Response reset(String id, List<Cursor> cursors) throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException, ConflictException, NakadiException { NakadiException.throwNonNull(id, "Please provide an id"); NakadiException.throwNonNull(cursors, "Please provide a cursors list"); return reset(retryPolicy, id, cursors); }
SubscriptionResourceReal implements SubscriptionResource { @Override public Response reset(String id, List<Cursor> cursors) throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException, ConflictException, NakadiException { NakadiException.throwNonNull(id, "Please provide an id"); NakadiException.throwNonNull(cursors, "Please provide a cursors list"); return reset(retryPolicy, id, cursors); } }
SubscriptionResourceReal implements SubscriptionResource { @Override public Response reset(String id, List<Cursor> cursors) throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException, ConflictException, NakadiException { NakadiException.throwNonNull(id, "Please provide an id"); NakadiException.throwNonNull(cursors, "Please provide a cursors list"); return reset(retryPolicy, id, cursors); } SubscriptionResourceReal(NakadiClient client); }
SubscriptionResourceReal implements SubscriptionResource { @Override public Response reset(String id, List<Cursor> cursors) throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException, ConflictException, NakadiException { NakadiException.throwNonNull(id, "Please provide an id"); NakadiException.throwNonNull(cursors, "Please provide a cursors list"); return reset(retryPolicy, id, cursors); } SubscriptionResourceReal(NakadiClient client); @Deprecated @Override SubscriptionResource scope(String scope); @Override SubscriptionResource retryPolicy(RetryPolicy retryPolicy); @Override Response createReturningResponse(Subscription subscription); @Override Subscription create(Subscription subscription); @Override Subscription find(String id); @Override Optional<Subscription> tryFind(String id); @Override SubscriptionCollection list(); @Override SubscriptionCollection list(QueryParams params); @Override Response delete(String id); @Override CursorCommitResultCollection checkpoint(Map<String, String> context, Cursor... cursors); @Override Response reset(String id, List<Cursor> cursors); @Override SubscriptionCursorCollection cursors(String id); @Override SubscriptionEventTypeStatsCollection stats(String id); }
SubscriptionResourceReal implements SubscriptionResource { @Override public Response reset(String id, List<Cursor> cursors) throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException, ConflictException, NakadiException { NakadiException.throwNonNull(id, "Please provide an id"); NakadiException.throwNonNull(cursors, "Please provide a cursors list"); return reset(retryPolicy, id, cursors); } SubscriptionResourceReal(NakadiClient client); @Deprecated @Override SubscriptionResource scope(String scope); @Override SubscriptionResource retryPolicy(RetryPolicy retryPolicy); @Override Response createReturningResponse(Subscription subscription); @Override Subscription create(Subscription subscription); @Override Subscription find(String id); @Override Optional<Subscription> tryFind(String id); @Override SubscriptionCollection list(); @Override SubscriptionCollection list(QueryParams params); @Override Response delete(String id); @Override CursorCommitResultCollection checkpoint(Map<String, String> context, Cursor... cursors); @Override Response reset(String id, List<Cursor> cursors); @Override SubscriptionCursorCollection cursors(String id); @Override SubscriptionEventTypeStatsCollection stats(String id);  }