コード例 #1
0
  @Test(expected = IllegalArgumentException.class)
  public void testProjectWithDatasetParent()
      throws InvalidModelException, NotFoundException, DatastoreException, UnauthorizedException {
    String parentId = "123";
    // This is our parent header
    EntityHeader parentHeader = new EntityHeader();
    parentHeader.setId(parentId);
    parentHeader.setName("name");
    parentHeader.setType(EntityType.dataset.getEntityType());
    List<EntityHeader> path = new ArrayList<EntityHeader>();
    path.add(parentHeader);

    Project project = new Project();
    project.setParentId(parentId);
    // This should not be valid
    allTypesValidator.validateEntity(project, new EntityEvent(EventType.CREATE, path, null));
  }
コード例 #2
0
 @Test
 public void testEntityPath()
     throws JSONObjectAdapterException, ServletException, IOException, NotFoundException,
         DatastoreException {
   Project p = new Project();
   p.setName("EntityPath");
   p.setEntityType(p.getClass().getName());
   Project clone = (Project) entityServletHelper.createEntity(p, TEST_USER1);
   String id = clone.getId();
   toDelete.add(id);
   EntityPath path = entityServletHelper.getEntityPath(id, TEST_USER1);
   assertNotNull(path);
   assertNotNull(path.getPath());
   assertEquals(2, path.getPath().size());
   EntityHeader header = path.getPath().get(1);
   assertNotNull(header);
   assertEquals(id, header.getId());
 }
コード例 #3
0
  @Test
  public void testEntityTypeBatch() throws Exception {
    List<String> ids = new ArrayList<String>();
    for (int i = 0; i < 12; i++) {
      Project p = new Project();
      p.setName("EntityTypeBatchItem" + i);
      p.setEntityType(p.getClass().getName());
      Project clone = (Project) entityServletHelper.createEntity(p, TEST_USER1);
      String id = clone.getId();
      toDelete.add(id);
      ids.add(id);
    }

    BatchResults<EntityHeader> results = entityServletHelper.getEntityTypeBatch(ids, TEST_USER1);
    assertNotNull(results);
    assertEquals(12, results.getTotalNumberOfResults());
    List<String> outputIds = new ArrayList<String>();
    for (EntityHeader header : results.getResults()) {
      outputIds.add(header.getId());
    }
    assertEquals(ids.size(), outputIds.size());
    assertTrue(ids.containsAll(outputIds));
  }