use of org.sagebionetworks.repo.model.Study in project Synapse-Repository-Services by Sage-Bionetworks.
the class StackStatusInterceptorTest method testPostWithReadWrite.
@Test
public void testPostWithReadWrite() throws Exception {
// We should be able to get when the status is read-write
assertEquals(StatusEnum.READ_WRITE, stackStatusDao.getCurrentStatus());
Study child = new Study();
child.setParentId(sampleProject.getId());
Study fetched = ServletTestHelper.createEntity(dispatchServlet, child, userName);
assertNotNull(fetched);
}
use of org.sagebionetworks.repo.model.Study in project Synapse-Repository-Services by Sage-Bionetworks.
the class DefaultControllerAutowiredAllTypesTest method createEntitesOfEachType.
/**
* This is a test helper method that will create at least on of each type of entity.
* @return
* @throws IOException
* @throws ServletException
* @throws InvalidModelException
* @throws IllegalAccessException
* @throws InstantiationException
* @throws UnauthorizedException
* @throws NotFoundException
* @throws DatastoreException
*/
private List<Entity> createEntitesOfEachType(int countPerType) throws ServletException, IOException, InstantiationException, IllegalAccessException, InvalidModelException, DatastoreException, NotFoundException, UnauthorizedException {
// For now put each object in a project so their parent id is not null;
// Create a project
Project project = new Project();
project.setName("createAtLeastOneOfEachType");
project = ServletTestHelper.createEntity(dispatchServlet, project, userName);
assertNotNull(project);
toDelete.add(project.getId());
// Create a dataset
Study datasetParent = (Study) ObjectTypeFactory.createObjectForTest("datasetParent", EntityType.dataset, project.getId());
datasetParent = ServletTestHelper.createEntity(dispatchServlet, datasetParent, userName);
// Create a layer parent
Data layerParent = (Data) ObjectTypeFactory.createObjectForTest("layerParent", EntityType.layer, datasetParent.getId());
layerParent = ServletTestHelper.createEntity(dispatchServlet, layerParent, userName);
// Now get the path of the layer
List<EntityHeader> path = entityController.getEntityPath(userName, layerParent.getId());
// This is the list of entities that will be created.
List<Entity> newChildren = new ArrayList<Entity>();
// Create one of each type
EntityType[] types = EntityType.values();
for (int i = 0; i < countPerType; i++) {
int index = i;
Study dataset = null;
for (EntityType type : types) {
String name = type.name() + index;
// use the correct parent type.
String parentId = findCompatableParentId(path, type);
Entity object = ObjectTypeFactory.createObjectForTest(name, type, parentId);
Entity clone = ServletTestHelper.createEntity(dispatchServlet, object, userName);
assertNotNull(clone);
assertNotNull(clone.getId());
assertNotNull(clone.getEtag());
// Mark entities for deletion after the current test completes
toDelete.add(clone.getId());
// Stash these for later use
if (EntityType.dataset == type) {
dataset = (Study) clone;
}
// Check the base urls
UrlHelpers.validateAllUrls(clone);
// Add this to the list of entities created
newChildren.add(clone);
index++;
}
}
return newChildren;
}
use of org.sagebionetworks.repo.model.Study in project Synapse-Repository-Services by Sage-Bionetworks.
the class EntityServiceImplAutowiredTest method createForTest.
private Study createForTest(int i) {
Study ds = new Study();
ds.setName("someName" + i);
ds.setDescription("someDesc" + i);
ds.setCreatedBy("magic" + i);
ds.setCreatedOn(new Date(1001));
ds.setAnnotations("someAnnoUrl" + 1);
ds.setUri("someUri" + i);
return ds;
}
use of org.sagebionetworks.repo.model.Study in project Synapse-Repository-Services by Sage-Bionetworks.
the class EntityServiceImplAutowiredTest method testQuery.
@Test
public void testQuery() throws DatastoreException, NotFoundException, UnauthorizedException {
// Basic query
PaginatedResults<Study> paginated = entityController.getEntities(userName, new PaginatedParameters(1, 100, null, true), mockRequest, Study.class);
assertNotNull(paginated);
assertNotNull(paginated.getPaging());
List<Study> results = paginated.getResults();
assertNotNull(results);
assertEquals(totalEntities, results.size());
// Check the urls for each object
for (Study ds : results) {
UrlHelpers.validateAllUrls(ds);
}
// Sorted
paginated = entityController.getEntities(userName, new PaginatedParameters(1, 3, "name", true), mockRequest, Study.class);
results = paginated.getResults();
assertNotNull(results);
assertEquals(3, results.size());
assertNotNull(results.get(2));
assertEquals("someName2", results.get(2).getName());
}
use of org.sagebionetworks.repo.model.Study in project Synapse-Repository-Services by Sage-Bionetworks.
the class EntityServiceImplAutowiredTest method before.
@Before
public void before() throws DatastoreException, InvalidModelException, NotFoundException, UnauthorizedException {
assertNotNull(entityController);
assertNotNull(testUserProvider);
// Map test objects to their urls
// Make sure we have a valid user.
userInfo = testUserProvider.getTestAdminUserInfo();
UserInfo.validateUserInfo(userInfo);
userName = userInfo.getUser().getUserId();
mockRequest = Mockito.mock(HttpServletRequest.class);
when(mockRequest.getServletPath()).thenReturn("/repo/v1");
toDelete = new ArrayList<String>();
// Create a project to hold the datasets
Project project = new Project();
project.setName("projectRoot");
project = entityController.createEntity(userName, project, mockRequest);
assertNotNull(project);
// Create some datasetst.
for (int i = 0; i < totalEntities; i++) {
Study ds = createForTest(i);
ds.setParentId(project.getId());
ds = entityController.createEntity(userName, ds, mockRequest);
for (int layer = 0; layer < layers; layer++) {
Data inLayer = createLayerForTest(i * 10 + layer);
inLayer.setParentId(ds.getId());
inLayer.setMd5("b960413cf33e1333b2b709319c29870d");
List<LocationData> locationDatas = new ArrayList<LocationData>();
inLayer.setLocations(locationDatas);
for (int loc = 0; loc < locations; loc++) {
LocationData loca = createLayerLocatoinsForTest(i * 10 + layer * 10 + loc);
locationDatas.add(loca);
}
inLayer = entityController.createEntity(userName, inLayer, mockRequest);
}
toDelete.add(ds.getId());
}
toDelete.add(project.getId());
}
Aggregations