Skip to content

Commit 3fa87f9

Browse files
committed
Adding test with multiple authors and verifying payment amounts
1 parent 136cfd1 commit 3fa87f9

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/test/java/org/whispersystems/bithub/tests/controllers/GithubControllerTest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535

3636
import static org.fest.assertions.api.Assertions.assertThat;
3737
import static org.mockito.Matchers.*;
38-
import static org.mockito.Mockito.mock;
39-
import static org.mockito.Mockito.verify;
40-
import static org.mockito.Mockito.when;
38+
import static org.mockito.Mockito.*;
4139

4240
public class GithubControllerTest extends ResourceTest {
4341

@@ -100,4 +98,18 @@ public void testValidCommit() throws Exception, TransferFailedException {
10098
anyString());
10199
}
102100

101+
@Test
102+
public void testValidMultipleCommitsMultipleAuthors() throws Exception, TransferFailedException {
103+
String payloadValue = "{\"after\":\"1481a2de7b2a7d02428ad93446ab166be7793fbb\",\"before\":\"17c497ccc7cca9c2f735aa07e9e3813060ce9a6a\",\"commits\":[{\"added\":[],\"author\":{\"email\":\"[email protected]\",\"name\":\"Garen Torikian\",\"username\":\"octokitty\"},\"committer\":{\"email\":\"[email protected]\",\"name\":\"Garen Torikian\",\"username\":\"octokitty\"},\"distinct\":true,\"id\":\"c441029cf673f84c8b7db52d0a5944ee5c52ff89\",\"message\":\"Test\",\"modified\":[\"README.md\"],\"removed\":[],\"timestamp\":\"2013-02-22T13:50:07-08:00\",\"url\":\"https://github.com/octokitty/testing/commit/c441029cf673f84c8b7db52d0a5944ee5c52ff89\"},{\"added\":[],\"author\":{\"email\":\"[email protected]\",\"name\":\"Garen Torikian\",\"username\":\"octokitty\"},\"committer\":{\"email\":\"[email protected]\",\"name\":\"Garen Torikian\",\"username\":\"octokitty\"},\"distinct\":true,\"id\":\"36c5f2243ed24de58284a96f2a643bed8c028658\",\"message\":\"This is me testing the windows client.\",\"modified\":[\"README.md\"],\"removed\":[],\"timestamp\":\"2013-02-22T14:07:13-08:00\",\"url\":\"https://github.com/octokitty/testing/commit/36c5f2243ed24de58284a96f2a643bed8c028658\"},{\"added\":[\"words/madame-bovary.txt\"],\"author\":{\"email\":\"[email protected]\",\"name\":\"Garen Torikian\",\"username\":\"octokitty\"},\"committer\":{\"email\":\"[email protected]\",\"name\":\"Garen Torikian\",\"username\":\"octokitty\"},\"distinct\":true,\"id\":\"1481a2de7b2a7d02428ad93446ab166be7793fbb\",\"message\":\"Rename madame-bovary.txt to words/madame-bovary.txt\",\"modified\":[],\"removed\":[\"madame-bovary.txt\"],\"timestamp\":\"2013-03-12T08:14:29-07:00\",\"url\":\"https://github.com/octokitty/testing/commit/1481a2de7b2a7d02428ad93446ab166be7793fbb\"}],\"compare\":\"https://github.com/octokitty/testing/compare/17c497ccc7cc...1481a2de7b2a\",\"created\":false,\"deleted\":false,\"forced\":false,\"head_commit\":{\"added\":[\"words/madame-bovary.txt\"],\"author\":{\"email\":\"[email protected]\",\"name\":\"Garen Torikian\",\"username\":\"octokitty\"},\"committer\":{\"email\":\"[email protected]\",\"name\":\"Garen Torikian\",\"username\":\"octokitty\"},\"distinct\":true,\"id\":\"1481a2de7b2a7d02428ad93446ab166be7793fbb\",\"message\":\"Rename madame-bovary.txt to words/madame-bovary.txt\",\"modified\":[],\"removed\":[\"madame-bovary.txt\"],\"timestamp\":\"2013-03-12T08:14:29-07:00\",\"url\":\"https://github.com/octokitty/testing/commit/1481a2de7b2a7d02428ad93446ab166be7793fbb\"},\"pusher\":{\"email\":\"[email protected]\",\"name\":\"Garen Torikian\"},\"ref\":\"refs/heads/master\",\"repository\":{\"created_at\":1332977768,\"description\":\"\",\"fork\":false,\"forks\":0,\"has_downloads\":true,\"has_issues\":true,\"has_wiki\":true,\"homepage\":\"\",\"id\":3860742,\"language\":\"Ruby\",\"master_branch\":\"master\",\"name\":\"testing\",\"open_issues\":2,\"owner\":{\"email\":\"[email protected]\",\"name\":\"octokitty\"},\"private\":false,\"pushed_at\":1363295520,\"size\":2156,\"stargazers\":1,\"url\":\"https://github.com/moxie0/test\",\"watchers\":1}}";
104+
MultivaluedMapImpl post = new MultivaluedMapImpl();
105+
post.add("payload", payloadValue);
106+
ClientResponse response = client().resource("/v1/github/commits/").header("X-Forwarded-For", "192.30.252.1")
107+
.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).post(ClientResponse.class, post);
108+
109+
verify(coinbaseClient, times(1)).sendPayment(any(Author.class), eq(BALANCE.multiply(new BigDecimal(0.02))),
110+
anyString());
111+
verify(coinbaseClient, times(1)).sendPayment(any(Author.class), eq(BALANCE.subtract(BALANCE.multiply(new BigDecimal(0.02)))
112+
.multiply(new BigDecimal(0.02))), anyString());
113+
}
114+
103115
}

0 commit comments

Comments
 (0)