@Test
  public void testPLFM_1288() throws Exception {
    Project p = new Project();
    p.setName("Create without entity type");
    p.setEntityType(p.getClass().getName());
    p = (Project) entityServletHelper.createEntity(p, TEST_USER1);
    toDelete.add(p.getId());

    Study one = new Study();
    one.setName("one");
    one.setParentId(p.getId());
    one.setEntityType(Study.class.getName());
    one = (Study) entityServletHelper.createEntity(one, TEST_USER1);
    // Now try to re-use the name
    Code two = new Code();
    two.setName("code");
    two.setParentId(one.getId());
    two.setEntityType(Code.class.getName());
    try {
      two = (Code) entityServletHelper.createEntity(two, TEST_USER1);
      fail("Code cannot have a parent of type Study");
    } catch (IllegalArgumentException e) {
      System.out.println(e.getMessage());
      assertTrue(e.getMessage().indexOf(Code.class.getName()) > 0);
      assertTrue(e.getMessage().indexOf(Study.class.getName()) > 0);
    }
  }
  /** @throws Exception */
  @Test
  public void testCreateS3TokenRelativePath() throws Exception {
    Code code = new Code();
    code.setParentId(project.getId());
    code = testHelper.createEntity(code, null);

    // a relative path to a file
    String initialPath = "foo.java";
    S3Token token = new S3Token();
    token.setPath(initialPath);
    token.setMd5(TEST_MD5);

    token = testHelper.createObject(code.getS3Token(), token);

    assertEquals(StackConfiguration.getS3Bucket(), token.getBucket());
    assertTrue(
        token
            .getPath()
            .matches("^/" + KeyFactory.stringToKey(code.getId()) + "/\\d+/" + initialPath + "$"));
    assertEquals(TEST_MD5, token.getMd5());
    assertEquals("text/plain", token.getContentType());
    assertNotNull(token.getSecretAccessKey());
    assertNotNull(token.getAccessKeyId());
    assertNotNull(token.getSessionToken());
    assertTrue(token.getPresignedUrl().matches("^http.*" + initialPath + ".*"));
  }