This repository has been archived by the owner on Jan 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Peer service initial commit * Change version * Update client for when no ID is provided * Add tests * Fix comment, add newline * 1kgenomes as default peer * Change to url
- Loading branch information
Showing
17 changed files
with
217 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
cts-java/src/test/java/org/ga4gh/cts/api/peers/PeersIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org.ga4gh.cts.api.peers; | ||
|
||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import com.mashape.unirest.http.exceptions.UnirestException; | ||
import ga4gh.PeerServiceOuterClass; | ||
import ga4gh.PeerServiceOuterClass.ListPeersRequest; | ||
import ga4gh.PeerServiceOuterClass.ListPeersResponse; | ||
import ga4gh.PeerServiceOuterClass.GetInfoResponse; | ||
import ga4gh.PeerServiceOuterClass.GetInfoRequest; | ||
import ga4gh.PeerServiceOuterClass.AnnouncePeerRequest; | ||
import ga4gh.PeerServiceOuterClass.AnnouncePeerResponse; | ||
import ga4gh.PeerServiceOuterClass.Peer; | ||
import org.ga4gh.ctk.transport.GAWrapperException; | ||
import org.ga4gh.ctk.transport.URLMAPPING; | ||
import org.ga4gh.ctk.transport.protocols.Client; | ||
import org.ga4gh.cts.api.TestData; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Tests for the BioMetadata endpoints | ||
*/ | ||
@Category(PeersTests.class) | ||
public class PeersIT { | ||
|
||
private static Client client = new Client(URLMAPPING.getInstance()); | ||
|
||
/** | ||
* Tests the /peers/list endpoint to ensure a well formed peer (1kgenomes.ga4gh.org) is returned. | ||
* @throws GAWrapperException if the server finds the request invalid in some way | ||
* @throws UnirestException if there's a problem speaking HTTP to the server | ||
* @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server | ||
*/ | ||
@Test | ||
public void checkListPeers() throws InvalidProtocolBufferException, UnirestException, GAWrapperException { | ||
final ListPeersRequest req = | ||
ListPeersRequest.newBuilder() | ||
.build(); | ||
|
||
final ListPeersResponse resp = client.peers.listPeers(req); | ||
assertThat(resp.getPeersCount()).isGreaterThan(0); | ||
final Peer peer = Peer.newBuilder().setUrl("http://1kgenomes.ga4gh.org").build(); | ||
assertThat(resp.getPeersList()).contains(peer); | ||
} | ||
|
||
/** | ||
* Tests that the service will receive a well formed announce message without throwing an error. | ||
* @throws GAWrapperException if the server finds the request invalid in some way | ||
* @throws UnirestException if there's a problem speaking HTTP to the server | ||
* @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server | ||
*/ | ||
@Test | ||
public void checkValidAnnounce() throws InvalidProtocolBufferException, UnirestException, GAWrapperException { | ||
final Peer peer = Peer.newBuilder().setUrl("http://1kgenomes.ga4gh.org").build(); | ||
final AnnouncePeerRequest req = | ||
AnnouncePeerRequest.newBuilder() | ||
.setPeer(peer) | ||
.build(); | ||
|
||
final AnnouncePeerResponse resp = client.peers.announcePeer(req); | ||
assertThat(resp).isNotNull(); | ||
assertThat(resp.getSuccess()).isTrue(); | ||
} | ||
|
||
/** | ||
* Tests that the service returns an expected info response at the /info endpoint including the protocol version. | ||
* @throws GAWrapperException if the server finds the request invalid in some way | ||
* @throws UnirestException if there's a problem speaking HTTP to the server | ||
* @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server | ||
*/ | ||
@Test | ||
public void checkGetInfo() throws InvalidProtocolBufferException, UnirestException, GAWrapperException { | ||
final GetInfoResponse resp = client.peers.getInfo(); | ||
assertThat(resp).isNotNull(); | ||
assertThat(resp.getProtocolVersion()).isNotEmpty(); | ||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
cts-java/src/test/java/org/ga4gh/cts/api/peers/PeersTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.ga4gh.cts.api.peers; | ||
|
||
|
||
public interface PeersTests { /* category marker */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters