@Override protected com.linecorp.centraldogma.common.Author doBackward(Author author) { return new com.linecorp.centraldogma.common.Author(author.getName(), author.getEmail()); } }
@Override protected com.linecorp.centraldogma.common.Author doBackward(Author author) { return new com.linecorp.centraldogma.common.Author(author.getName(), author.getEmail()); } }
public static Author currentAuthor(ServiceRequestContext ctx) { final User user = ctx.attr(CURRENT_USER_KEY).get(); assert user != null; return user == User.DEFAULT ? Author.DEFAULT : new Author(user.name(), user.email()); }
public static Author currentAuthor(ServiceRequestContext ctx) { final User user = ctx.attr(CURRENT_USER_KEY).get(); assert user != null; return user == User.DEFAULT ? Author.DEFAULT : new Author(user.name(), user.email()); }
public static Author currentAuthor(ServiceRequestContext ctx) { final User user = ctx.attr(CURRENT_USER_KEY).get(); assert user != null; return user == User.DEFAULT ? Author.DEFAULT : new Author(user.name(), user.email()); }
@Test public void testAuthor_invalidParameters() { try { new Author(null, "email@test.com"); fail("Expected NullPointerException"); } catch (NullPointerException ignored) { } try { new Author("", "invalid mail address"); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException ignored) { } }
@Test public void testJsonConversion() { assertJsonConversion(new CreateProjectCommand(1234L, new Author("foo", "bar@baz.com"), "foo"), Command.class, '{' + " \"type\": \"CREATE_PROJECT\"," + " \"timestamp\": 1234," + " \"author\": {" + " \"name\": \"foo\"," + " \"email\": \"bar@baz.com\"" + " }," + " \"projectName\": \"foo\"" + '}'); }
@Test public void testJsonConversion() { TestUtil.assertJsonConversion(new Author("Homer Simpson", "homer@simpsonsworld.com"), '{' + " \"name\": \"Homer Simpson\"," + " \"email\": \"homer@simpsonsworld.com\"" + '}'); TestUtil.assertJsonConversion(new Author("bart@simpsonsworld.com"), '{' + " \"name\": \"bart@simpsonsworld.com\"," + " \"email\": \"bart@simpsonsworld.com\"" + '}'); } }
@Test public void testJsonConversion() { assertJsonConversion(new CreateRepositoryCommand(1234L, new Author("foo", "bar@baz.com"), "foo", "bar"), Command.class, '{' + " \"type\": \"CREATE_REPOSITORY\"," + " \"timestamp\": 1234," + " \"author\": {" + " \"name\": \"foo\"," + " \"email\": \"bar@baz.com\"" + " }," + " \"projectName\": \"foo\"," + " \"repositoryName\": \"bar\"" + '}'); }
@Test public void testJsonConversion() { assertJsonConversion( new RemoveSessionCommand(1234L, new Author("foo", "bar@baz.com"), "some-id"), Command.class, '{' + " \"type\": \"REMOVE_SESSIONS\"," + " \"timestamp\": 1234," + " \"author\": {" + " \"name\": \"foo\"," + " \"email\": \"bar@baz.com\"" + " }," + " \"sessionId\": \"some-id\"" + '}'); } }
private static Commit toCommit(RevCommit revCommit) { final Author author; final PersonIdent committerIdent = revCommit.getCommitterIdent(); final long when; if (committerIdent == null) { author = Author.UNKNOWN; when = 0; } else { author = new Author(committerIdent.getName(), committerIdent.getEmailAddress()); when = committerIdent.getWhen().getTime(); } try { return CommitUtil.newCommit(author, when, revCommit.getFullMessage()); } catch (Exception e) { throw new StorageException("failed to create a Commit", e); } }
private static Commit toCommit(RevCommit revCommit) { final Author author; final PersonIdent committerIdent = revCommit.getCommitterIdent(); final long when; if (committerIdent == null) { author = Author.UNKNOWN; when = 0; } else { author = new Author(committerIdent.getName(), committerIdent.getEmailAddress()); when = committerIdent.getWhen().getTime(); } try { return CommitUtil.newCommit(author, when, revCommit.getFullMessage()); } catch (Exception e) { throw new StorageException("failed to create a Commit", e); } }
private static Commit toCommit(RevCommit revCommit) { final Author author; final PersonIdent committerIdent = revCommit.getCommitterIdent(); final long when; if (committerIdent == null) { author = Author.UNKNOWN; when = 0; } else { author = new Author(committerIdent.getName(), committerIdent.getEmailAddress()); when = committerIdent.getWhen().getTime(); } try { return CommitUtil.newCommit(author, when, revCommit.getFullMessage()); } catch (Exception e) { throw new StorageException("failed to create a Commit", e); } }
@Test public void push() throws Exception { doAnswer(invocation -> { final AsyncMethodCallback<TCommit> callback = invocation.getArgument(7); callback.onComplete(new TCommit( new TRevision(1), new TAuthor("name", "name@sample.com"), TIMESTAMP, "summary", new Comment("detail"), ImmutableList.of())); return null; }).when(iface).push(anyString(), anyString(), any(), any(), any(), any(), any(), any()); assertThat(client.push("project", "repo", new Revision(1), new Author("name", "name@sample.com"), "summary", "detail", Markup.PLAINTEXT, ImmutableList.of(Change.ofTextUpsert("/a.txt", "hello")) ).get()).isEqualTo(new PushResult(new Revision(1), Instant.parse(TIMESTAMP).toEpochMilli())); verify(iface).push(eq("project"), eq("repo"), any(), any(), eq("summary"), any(), any(), any()); }
@Test public void getHistory() throws Exception { doAnswer(invocation -> { final AsyncMethodCallback<List<TCommit>> callback = invocation.getArgument(5); callback.onComplete(ImmutableList.of(new TCommit( new TRevision(1), new TAuthor("name", "name@sample.com"), TIMESTAMP, "summary", new Comment("detail").setMarkup(TMarkup.PLAINTEXT), ImmutableList.of(new TChange("/a.txt", ChangeType.UPSERT_TEXT).setContent("content"))))); return null; }).when(iface).getHistory(any(), any(), any(), any(), any(), any()); assertThat(client.getHistory("project", "repo", new Revision(1), new Revision(3), "path").get()) .isEqualTo(ImmutableList.of(new Commit(new Revision(1), new Author("name", "name@sample.com"), Instant.parse(TIMESTAMP).toEpochMilli(), "summary", "detail", Markup.PLAINTEXT))); verify(iface).getHistory(eq("project"), eq("repo"), any(), any(), eq("path"), any()); }
@Test public void listRepositories() throws Exception { doAnswer(invocation -> { final AsyncMethodCallback<List<Repository>> callback = invocation.getArgument(1); final Repository repository = new Repository("repo").setHead( new TCommit(new TRevision(42), new TAuthor("hitchhiker", "arthur@dent.com"), "1978-03-08T00:00:00Z", "The primary phrase", new Comment(""), null)); callback.onComplete(ImmutableList.of(repository)); return null; }).when(iface).listRepositories(any(), any()); assertThat(client.listRepositories("project").get()).isEqualTo(ImmutableMap.of( "repo", new RepositoryInfo( "repo", new Commit(new Revision(42), new Author("hitchhiker", "arthur@dent.com"), Instant.parse("1978-03-08T00:00:00Z").toEpochMilli(), "The primary phrase", "", Markup.PLAINTEXT)))); verify(iface).listRepositories(eq("project"), any()); }
@Test public void testJsonConversion() { assertJsonConversion( new PushCommand(1234L, new Author("Marge Simpson", "marge@simpsonsworld.com"), "foo", "bar", new Revision(42), "baz", "qux", Markup.MARKDOWN, Collections.singletonList(Change.ofTextUpsert("/memo.txt", "Bon voyage!"))), Command.class, '{' + " \"type\": \"PUSH\"," + " \"timestamp\": 1234," + " \"author\": {" + " \"name\": \"Marge Simpson\"," + " \"email\": \"marge@simpsonsworld.com\"" + " }," + " \"projectName\": \"foo\"," + " \"repositoryName\": \"bar\"," + " \"baseRevision\": 42," + " \"summary\": \"baz\"," + " \"detail\": \"qux\"," + " \"markup\": \"MARKDOWN\"," + " \"changes\": [{" + " \"type\": \"UPSERT_TEXT\"," + " \"path\": \"/memo.txt\"," + " \"content\": \"Bon voyage!\"" + " }]" + '}'); }
assertThat(c.repositoryName()).isEqualTo("bar"); assertThat(c.baseRevision()).isEqualTo(new Revision(42)); assertThat(c.author()).isEqualTo(new Author("Marge Simpson", "marge@simpsonsworld.com")); assertThat(c.summary()).isEqualTo("baz"); assertThat(c.detail()).isEqualTo("qux");
new Author("foo", "bar@baz.com"), session));
1234L, new Author("Sedol Lee", "sedol@lee.com"), "foo", "bar", Revision.HEAD, "4:1", "L-L-L-W-L", Markup.PLAINTEXT, Change.ofTextUpsert("/result.txt", "too soon to tell"));