Skip to content

Commit

Permalink
ZooniverseClient: Retrieve project by slug
Browse files Browse the repository at this point in the history
This parses (not completely) the Project JSON structure returned by
the newer (live as of several months ago) backend.

For instance, this gives us the workflow IDs, so we can get the JSON
for a Workflow.
  • Loading branch information
murraycu committed Jan 10, 2019
1 parent 3988a06 commit 4df0f9d
Show file tree
Hide file tree
Showing 6 changed files with 902 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,42 @@ public void testMoreItems() throws IOException, InterruptedException, Zooniverse
server.shutdown();
}

@Test
public void testProject() throws IOException, ZooniverseClient.RequestProjectException {
final MockWebServer server = new MockWebServer();

final String strResponse = getStringFromStream(
MoreItemsJsonParserTest.class.getClassLoader().getResourceAsStream("test_project_response.json"));
assertNotNull(strResponse);
server.enqueue(new MockResponse().setBody(strResponse));
server.start();

final ZooniverseClient client = createZooniverseClient(server);

final ZooniverseClient.Project project = client.requestProjectSync("zookeeper/galaxy-zoo");
assertNotNull(project);

assertNotNull(project.id());
assertEquals("5733", project.id());

assertNotNull(project.displayName());
assertEquals("Galaxy Zoo", project.displayName());

final List<String> workflowIds = project.workflowIds();
assertNotNull(workflowIds);
assertEquals(5, workflowIds.size());

final List<String> activeWorkflowIds = project.activeWorkflowIds();
assertNotNull(activeWorkflowIds);
assertEquals(1, activeWorkflowIds.size());

final String activeWorkflowID = activeWorkflowIds.get(0);
assertNotNull(activeWorkflowID);
assertEquals("6122", activeWorkflowID);

server.shutdown();
}

@Test
public void testLoginWithSuccess() throws IOException, InterruptedException, ZooniverseClient.LoginException {
final MockWebServer server = new MockWebServer();
Expand Down
Loading

0 comments on commit 4df0f9d

Please sign in to comment.