@Test public void testPostPublishAndDelete() throws Throwable { URL fileUrl = getClass().getClassLoader().getResource("net/toxbank/client/test/BII-I-1.zip"); Investigation newInvestigation = new Investigation(); newInvestigation.setSearchable(false); RemoteTask task = getToxBankClient() .postInvestigation( new File(fileUrl.toURI()), new URL(INVESTIGATION_ROOT), new ArrayList<PolicyRule>(0), newInvestigation, null); task.waitUntilCompleted(1000); URL postedURL = task.getResult(); System.out.println("Posted new investigation: " + postedURL); Investigation investigation = getToxBankClient().getInvestigation(postedURL); verifyBiiInvestigation(investigation, false); TestCase.assertNotNull("Should have owner", investigation.getOwner()); TestCase.assertEquals(getUserUrl(), investigation.getOwner().getResourceURL().toString()); TestCase.assertNotNull("Should have a published status set", investigation.isPublished()); TestCase.assertEquals("Should not be published", Boolean.FALSE, investigation.isPublished()); task = getToxBankClient().publishInvestigation(investigation, true); task.waitUntilCompleted(1000); Investigation updatedInvestigation = getToxBankClient().getInvestigation(postedURL); TestCase.assertEquals(Boolean.TRUE, updatedInvestigation.isPublished()); System.out.println("Deleting investigation: " + investigation.getResourceURL()); getToxBankClient().deleteInvestigation(investigation.getResourceURL()); System.out.println("Deleted investigation: " + investigation.getResourceURL()); }
@Test public void testPostAndDeleteWithPermissions() throws Throwable { URL fileUrl = getClass().getClassLoader().getResource("net/toxbank/client/test/BII-I-1.zip"); List<PolicyRule> accessRights = createPolicyRules(); Investigation newInvestigation = new Investigation(); newInvestigation.setSearchable(false); RemoteTask task = getToxBankClient() .postInvestigation( new File(fileUrl.toURI()), new URL(INVESTIGATION_ROOT), accessRights, newInvestigation, null); task.waitUntilCompleted(1000); URL postedURL = task.getResult(); System.out.println("Posted new investigation: " + postedURL); Investigation investigation = getToxBankClient().getInvestigation(postedURL); verifyBiiInvestigation(investigation, false); verifyPolicyRules(investigation); String userUrl = getUserUrl(); TestCase.assertNotNull("Should have owner", investigation.getOwner()); TestCase.assertEquals(userUrl, investigation.getOwner().getResourceURL().toString()); User owner = new User(); URL ownerUrl = new URL(userUrl); owner.setResourceURL(ownerUrl); List<TimestampedUrl> userUrls = getToxBankClient().listTimestampedInvestigations(new URL(INVESTIGATION_ROOT), owner); boolean hasPostedUrl = false; for (TimestampedUrl url : userUrls) { if ((postedURL.toString() + "/").equals(url.getUrl().toString())) { hasPostedUrl = true; } } Assert.assertTrue( "The loaded investigation should be included in the owner's list", hasPostedUrl); System.out.println("Deleting investigation: " + investigation.getResourceURL()); getToxBankClient().deleteInvestigation(investigation.getResourceURL()); System.out.println("Deleted investigation: " + investigation.getResourceURL()); }
@Test public void testPostAndUpdate() throws Throwable { URL fileUrl = getClass().getClassLoader().getResource("net/toxbank/client/test/BII-I-1.zip"); Investigation newInvestigation = new Investigation(); newInvestigation.setSearchable(false); RemoteTask task = getToxBankClient() .postInvestigation( new File(fileUrl.toURI()), new URL(INVESTIGATION_ROOT), new ArrayList<PolicyRule>(0), newInvestigation, null); task.waitUntilCompleted(1000); URL postedURL = task.getResult(); System.out.println("Posted new investigation: " + postedURL); Investigation investigation = getToxBankClient().getInvestigation(postedURL); verifyBiiInvestigation(investigation, false); URL newFileUrl = getClass().getClassLoader().getResource("net/toxbank/client/test/BII-I-1-smiller.zip"); RemoteTask newTask = getToxBankClient() .updateInvestigation( new File(newFileUrl.toURI()), investigation, new ArrayList<PolicyRule>(0), null); newTask.waitUntilCompleted(1000); URL postedUpdateURL = task.getResult(); Assert.assertEquals( "Should have same update url as original posted url", postedURL, postedUpdateURL); System.out.println("Updated investigation: " + investigation.getResourceURL()); Investigation updatedInvestigation = getToxBankClient().getInvestigation(investigation.getResourceURL()); TestCase.assertEquals( "Should have new title in updated investigation", "Growth control of the eukaryote cell: a systems biology study in yeast - updated", updatedInvestigation.getTitle()); TestCase.assertNotNull( "Updated investigation should have owner", updatedInvestigation.getOwner()); TestCase.assertEquals( "Updated investigation should have same owner", getUserUrl(), updatedInvestigation.getOwner().getResourceURL().toString()); System.out.println("Deleting investigation: " + investigation.getResourceURL()); getToxBankClient().deleteInvestigation(investigation.getResourceURL()); System.out.println("Deleted investigation: " + investigation.getResourceURL()); }
@Test public void testPostAndUpdateRemovingPermissions() throws Throwable { URL fileUrl = getClass().getClassLoader().getResource("net/toxbank/client/test/BII-I-1.zip"); List<PolicyRule> accessRights = createPolicyRules(); Investigation newInvestigation = new Investigation(); newInvestigation.setSearchable(false); RemoteTask task = getToxBankClient() .postInvestigation( new File(fileUrl.toURI()), new URL(INVESTIGATION_ROOT), accessRights, newInvestigation, null); task.waitUntilCompleted(1000); URL postedURL = task.getResult(); System.out.println("Posted new investigation: " + postedURL); Investigation investigation = getToxBankClient().getInvestigation(postedURL); verifyBiiInvestigation(investigation, false); verifyPolicyRules(investigation); RemoteTask newTask = getToxBankClient().updateInvestigation(investigation, new ArrayList<PolicyRule>(0)); newTask.waitUntilCompleted(1000); URL postedUpdateURL = task.getResult(); Assert.assertEquals( "Should have same update url as original posted url", postedURL, postedUpdateURL); System.out.println("Updated investigation: " + investigation.getResourceURL()); Investigation updatedInvestigation = getToxBankClient().getInvestigation(investigation.getResourceURL()); verifyBiiInvestigation(updatedInvestigation, false); TestCase.assertNotNull( "Updated investigation should have owner", updatedInvestigation.getOwner()); TestCase.assertEquals( "Updated investigation should have same owner", getUserUrl(), updatedInvestigation.getOwner().getResourceURL().toString()); verifyOwnerOnlyPolicyRules(updatedInvestigation); System.out.println("Deleting investigation: " + investigation.getResourceURL()); getToxBankClient().deleteInvestigation(investigation.getResourceURL()); System.out.println("Deleted investigation: " + investigation.getResourceURL()); }