| package org.eclipse.fx.travisci.client; |
| |
| import java.util.concurrent.CountDownLatch; |
| |
| import org.eclipse.fx.travisci.client.BuildsEndpoint.BuildsQuery; |
| import org.eclipse.fx.travisci.client.impl.TravisCIClientImpl; |
| import org.junit.Assert; |
| import org.junit.Test; |
| |
| public class BuildsEndpointTestCase { |
| @Test |
| public void testCreateEndPoint() { |
| TravisCIClientImpl c = new TravisCIClientImpl("travis-java-client-test", "api.travis-ci.org"); |
| Assert.assertNotNull(c.createEndpoint(BuildsEndpoint.class)); |
| } |
| |
| |
| @Test |
| public void testGetBuilds() { |
| TravisCIClientImpl c = new TravisCIClientImpl("travis-java-client-test", "api.travis-ci.org"); |
| BuildsEndpoint endpoint = c.createEndpoint(BuildsEndpoint.class); |
| Assert.assertTrue(endpoint.getBuilds(BuildsQuery.byRepositoryId(3938495)).count() > 0); |
| Assert.assertTrue(endpoint.getBuilds(BuildsQuery.bySlug("tomsontom/compensator-samples")).count() > 0); |
| } |
| |
| @Test |
| public void testGetBuildsAsync() { |
| TravisCIClientImpl c = new TravisCIClientImpl("travis-java-client-test", "api.travis-ci.org"); |
| BuildsEndpoint endpoint = c.createEndpoint(BuildsEndpoint.class); |
| CountDownLatch l = new CountDownLatch(1); |
| endpoint.getBuilds(BuildsQuery.byRepositoryId(3938495), (s) -> { |
| Assert.assertTrue(s.count() > 0); |
| l.countDown(); |
| }, (t) -> |
| { |
| l.countDown(); |
| Assert.fail(t.getMessage()); |
| }); |
| try { |
| l.await(); |
| } catch (InterruptedException e) { |
| // TODO Auto-generated catch block |
| e.printStackTrace(); |
| } |
| } |
| } |