use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class SynapseTest method testCreateAccessApproval.
@Test
public void testCreateAccessApproval() throws Exception {
TermsOfUseAccessApproval aa = new TermsOfUseAccessApproval();
aa.setEntityType(aa.getClass().getName());
JSONObjectAdapter adapter = new JSONObjectAdapterImpl();
aa.writeToJSONObject(adapter);
StringEntity responseEntity = new StringEntity(adapter.toJSONString());
when(mockResponse.getEntity()).thenReturn(responseEntity);
synapse.createAccessApproval(aa);
}
use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class SynapseTest method testGetEntityReferencedBy.
@Test
public void testGetEntityReferencedBy() throws Exception {
Project proj2 = new Project();
proj2.setId("5");
proj2.setName("proj2");
EntityHeader proj1Header = new EntityHeader();
proj1Header.setId("id");
proj1Header.setName("name");
proj1Header.setType("type");
List<EntityHeader> eHeaderList = new ArrayList<EntityHeader>();
eHeaderList.add(proj1Header);
PaginatedResults<EntityHeader> paginatedResult = new PaginatedResults<EntityHeader>();
paginatedResult.setResults(eHeaderList);
paginatedResult.setTotalNumberOfResults(1);
paginatedResult.setPaging(new HashMap<String, String>());
// setup mock
JSONObjectAdapter adapter = new JSONObjectAdapterImpl();
paginatedResult.writeToJSONObject(adapter);
StringEntity responseEntity = new StringEntity(adapter.toJSONString());
when(mockResponse.getEntity()).thenReturn(responseEntity);
PaginatedResults<EntityHeader> realResults = synapse.getEntityReferencedBy(proj2);
assertEquals(1, realResults.getTotalNumberOfResults());
EntityHeader firstHeader = realResults.getResults().get(0);
assertEquals(proj1Header, firstHeader);
}
use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class SynapseTest method testCreateAccessRequirement.
@Test
public void testCreateAccessRequirement() throws Exception {
TermsOfUseAccessRequirement ar = new TermsOfUseAccessRequirement();
ar.setEntityType(ar.getClass().getName());
ar.setEntityIds(new ArrayList<String>());
ar.setAccessType(ACCESS_TYPE.DOWNLOAD);
ar.setTermsOfUse("foo");
JSONObjectAdapter adapter = new JSONObjectAdapterImpl();
ar.writeToJSONObject(adapter);
StringEntity responseEntity = new StringEntity(adapter.toJSONString());
when(mockResponse.getEntity()).thenReturn(responseEntity);
synapse.createAccessRequirement(ar);
}
use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class Synapse method getUnmetAccessReqAccessRequirements.
public VariableContentPaginatedResults<AccessRequirement> getUnmetAccessReqAccessRequirements(String entityId) throws SynapseException {
String uri = ENTITY + "/" + entityId + ACCESS_REQUIREMENT_UNFULFILLED;
JSONObject jsonAccessRequirements = getEntity(uri);
JSONObjectAdapter adapter = new JSONObjectAdapterImpl(jsonAccessRequirements);
VariableContentPaginatedResults<AccessRequirement> results = new VariableContentPaginatedResults<AccessRequirement>();
try {
results.initializeFromJSONObject(adapter);
return results;
} catch (JSONObjectAdapterException e) {
throw new SynapseException(e);
}
}
use of org.sagebionetworks.schema.adapter.org.json.JSONObjectAdapterImpl in project Synapse-Repository-Services by Sage-Bionetworks.
the class Synapse method getAnnotations.
/**
* Get the annotations for an entity.
* @param entityId
* @return
* @throws SynapseException
*/
public Annotations getAnnotations(String entityId) throws SynapseException {
String url = ENTITY_URI_PATH + "/" + entityId + "/annotations";
JSONObject jsonObj = getEntity(url);
JSONObjectAdapter adapter = new JSONObjectAdapterImpl(jsonObj);
Annotations annos = new Annotations();
try {
annos.initializeFromJSONObject(adapter);
return annos;
} catch (JSONObjectAdapterException e) {
throw new RuntimeException(e);
}
}
Aggregations