public WatchFileResult deepCopy() { return new WatchFileResult(this); }
public WatchFileResult deepCopy() { return new WatchFileResult(this); }
@Test public void watchFileTimedOut() throws Exception { doAnswer(invocation -> { AsyncMethodCallback<WatchFileResult> callback = invocation.getArgument(5); callback.onComplete(new WatchFileResult()); return null; }).when(iface).watchFile(any(), any(), any(), any(), anyLong(), any()); assertThat(client.watchFile("project", "repo", new Revision(1), Query.ofText("/a.txt"), 100).get()).isNull(); verify(iface).watchFile(eq("project"), eq("repo"), any(), any(), eq(100L), any()); } }
@Test public void watchFile() throws Exception { doAnswer(invocation -> { AsyncMethodCallback<WatchFileResult> callback = invocation.getArgument(5); callback.onComplete(new WatchFileResult().setRevision(new TRevision(42)) .setType(TEntryType.TEXT) .setContent("foo")); return null; }).when(iface).watchFile(any(), any(), any(), any(), anyLong(), any()); assertThat(client.watchFile("project", "repo", new Revision(1), Query.ofText("/a.txt"), 100).get()) .isEqualTo(Entry.ofText(new Revision(42), "/a.txt", "foo")); verify(iface).watchFile(eq("project"), eq("repo"), any(), any(), eq(100L), any()); }
private static void handleWatchFileResult( CompletableFuture<com.linecorp.centraldogma.common.Entry<Object>> future, AsyncMethodCallback resultHandler) { future.handle((res, cause) -> { if (cause == null) { final WatchFileResult wfr = new WatchFileResult(); wfr.setRevision(convert(res.revision())); wfr.setType(convert(res.type())); wfr.setContent(res.contentAsText()); resultHandler.onComplete(wfr); } else if (cause instanceof CancellationException) { resultHandler.onComplete(CentralDogmaConstants.EMPTY_WATCH_FILE_RESULT); } else { logAndInvokeOnError("watchFile", resultHandler, cause); } return null; }); }
private static void handleWatchFileResult( CompletableFuture<com.linecorp.centraldogma.common.Entry<Object>> future, AsyncMethodCallback resultHandler) { future.handle((res, cause) -> { if (cause == null) { final WatchFileResult wfr = new WatchFileResult(); wfr.setRevision(convert(res.revision())); wfr.setType(convert(res.type())); wfr.setContent(res.contentAsText()); resultHandler.onComplete(wfr); } else if (cause instanceof CancellationException) { resultHandler.onComplete(CentralDogmaConstants.EMPTY_WATCH_FILE_RESULT); } else { logAndInvokeOnError("watchFile", resultHandler, cause); } return null; }); }
private static void handleWatchFileResult( CompletableFuture<com.linecorp.centraldogma.common.Entry<Object>> future, AsyncMethodCallback resultHandler) { future.handle(voidFunction((res, cause) -> { if (cause == null) { final WatchFileResult wfr = new WatchFileResult(); wfr.setRevision(convert(res.revision())); wfr.setType(convert(res.type())); wfr.setContent(res.contentAsText()); resultHandler.onComplete(wfr); } else if (cause instanceof CancellationException) { resultHandler.onComplete(CentralDogmaConstants.EMPTY_WATCH_FILE_RESULT); } else { logAndInvokeOnError("watchFile", resultHandler, cause); } })); }