public GetFileResultDto(GetFileResult result) { type = result.getType(); content = result.getContent(); }
public GetFileResult deepCopy() { return new GetFileResult(this); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof GetFileResult) return this.equals((GetFileResult)that); return false; }
/** * Performs a deep copy on <i>other</i>. */ public GetFileResult(GetFileResult other) { if (other.isSetType()) { this.type = other.type; } if (other.isSetContent()) { this.content = other.content; } }
@Test public void thrift() throws Exception { final com.linecorp.centraldogma.internal.thrift.Revision head = new com.linecorp.centraldogma.internal.thrift.Revision(-1, 0); final Query query = new Query(PATH, QueryType.IDENTITY, ImmutableList.of()); // Should fail to decode without the decompressor. final Iface clientWithoutDecompressor = new ClientBuilder( "ttext+http://127.0.0.1:" + rule.serverAddress().getPort() + "/cd/thrift/v1") .setHttpHeader(HttpHeaderNames.AUTHORIZATION, "bearer " + CsrfToken.ANONYMOUS) .setHttpHeader(HttpHeaderNames.ACCEPT_ENCODING, "deflate") .build(Iface.class); assertThatThrownBy(() -> clientWithoutDecompressor.getFile(PROJ, REPO, head, query)) .isInstanceOf(TException.class) .hasCauseInstanceOf(JsonParseException.class); // Should succeed to decode with the decompressor. final Iface clientWithDecompressor = Clients.newDerivedClient( clientWithoutDecompressor, options -> new ClientOptionsBuilder(options) .decorator(HttpDecodingClient.newDecorator()) .build()); final GetFileResult result = clientWithDecompressor.getFile(PROJ, REPO, head, query); assertThat(result.getContent()).contains(CONTENT); }
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } }
/** * Performs a deep copy on <i>other</i>. */ public GetFileResult(GetFileResult other) { if (other.isSetType()) { this.type = other.type; } if (other.isSetContent()) { this.content = other.content; } }
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); } }
public GetFileResultDto(GetFileResult result) { type = result.getType(); content = result.getContent(); }
public GetFileResult deepCopy() { return new GetFileResult(this); }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case TYPE: return isSetType(); case CONTENT: return isSetContent(); } throw new IllegalStateException(); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof GetFileResult) return this.equals((GetFileResult)that); return false; }
public GetFileResultDto(GetFileResult result) { type = result.getType(); content = result.getContent(); }
@Test public void getFile() throws Exception { doAnswer(invocation -> { final AsyncMethodCallback<com.linecorp.centraldogma.internal.thrift.Revision> callback = invocation.getArgument(3); callback.onComplete(new com.linecorp.centraldogma.internal.thrift.Revision(1, 0)); return null; }).when(iface).normalizeRevision(any(), any(), any(), any()); doAnswer(invocation -> { final AsyncMethodCallback<GetFileResult> callback = invocation.getArgument(4); callback.onComplete(new GetFileResult(TEntryType.TEXT, "content")); return null; }).when(iface).getFile(any(), any(), any(), any(), any()); assertThat(client.getFile("project", "repo", new Revision(1), Query.ofText("/a.txt")).get()) .isEqualTo(Entry.ofText(new Revision(1), "/a.txt", "content")); verify(iface).getFile(eq("project"), eq("repo"), any(), any(), any()); }
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ public boolean isSet(_Fields field) { if (field == null) { throw new IllegalArgumentException(); } switch (field) { case TYPE: return isSetType(); case CONTENT: return isSetContent(); } throw new IllegalStateException(); }
public Object getFieldValue(_Fields field) { switch (field) { case TYPE: return getType(); case CONTENT: return getContent(); } throw new IllegalStateException(); }
@Test public void getFile_path() throws Exception { doAnswer(invocation -> { final AsyncMethodCallback<com.linecorp.centraldogma.internal.thrift.Revision> callback = invocation.getArgument(3); callback.onComplete(new com.linecorp.centraldogma.internal.thrift.Revision(1, 0)); return null; }).when(iface).normalizeRevision(any(), any(), any(), any()); doAnswer(invocation -> { final AsyncMethodCallback<GetFileResult> callback = invocation.getArgument(4); callback.onComplete(new GetFileResult(TEntryType.TEXT, "content")); return null; }).when(iface).getFile(any(), any(), any(), any(), any()); assertThat(client.getFile("project", "repo", new Revision(1), Query.ofText("/a.txt")).get()) .isEqualTo(Entry.ofText(new Revision(1), "/a.txt", "content")); verify(iface).getFile(eq("project"), eq("repo"), any(), any(), any()); }
public boolean equals(GetFileResult that) { if (that == null) return false; boolean this_present_type = true && this.isSetType(); boolean that_present_type = true && that.isSetType(); if (this_present_type || that_present_type) { if (!(this_present_type && that_present_type)) return false; if (!this.type.equals(that.type)) return false; } boolean this_present_content = true && this.isSetContent(); boolean that_present_content = true && that.isSetContent(); if (this_present_content || that_present_content) { if (!(this_present_content && that_present_content)) return false; if (!this.content.equals(that.content)) return false; } return true; }
public Object getFieldValue(_Fields field) { switch (field) { case TYPE: return getType(); case CONTENT: return getContent(); } throw new IllegalStateException(); }
@Override public void getFile(String projectName, String repositoryName, Revision revision, Query query, AsyncMethodCallback resultHandler) { handle(projectManager.get(projectName).repos().get(repositoryName) .get(convert(revision), convert(query)) .thenApply(res -> new GetFileResult(convert(res.type()), res.contentAsText())), resultHandler); }