Item extends DSpaceObject implements DSpaceObjectLegacySupport { public void setOwningCollection(Collection c) { this.owningCollection = c; setModified(); } protected  Item(); boolean isArchived(); boolean isWithdrawn(); boolean isDiscoverable(); Date getLastModified(); void setLastModified(Date lastModified); void setArchived(boolean isArchived); void setDiscoverable(boolean discoverable); void setOwningCollection(Collection c); Collection getOwningCollection(); EPerson getSubmitter(); void setSubmitter(EPerson sub); List<Collection> getCollections(); void clearCollections(); Collection getTemplateItemOf(); List<Bundle> getBundles(); List<Bundle> getBundles(String name); @Override boolean equals(Object obj); @Override int hashCode(); @Override int getType(); @Override String getName(); @Override Integer getLegacyId(); ItemService getItemService(); static final String ANY; }
@Test public void testSetOwningCollection() throws SQLException, AuthorizeException { context.turnOffAuthorisationSystem(); Collection c = createCollection(); context.restoreAuthSystemState(); it.setOwningCollection(c); assertThat("testSetOwningCollection 0", it.getOwningCollection(), notNullValue()); assertThat("testSetOwningCollection 1", it.getOwningCollection(), equalTo(c)); }
@Test public void testUpdateAuth2() throws Exception { context.turnOffAuthorisationSystem(); Collection c = createCollection(); it.setOwningCollection(c); context.restoreAuthSystemState(); doNothing().when(authorizeServiceSpy).authorizeAction(context, c, Constants.WRITE, false); itemService.update(context, it); }
@Test(expected = AuthorizeException.class) public void testUpdateNoAuth() throws Exception { context.turnOffAuthorisationSystem(); Collection c = createCollection(); it.setOwningCollection(c); context.restoreAuthSystemState(); itemService.update(context, it); }
@Test public void testCanEditBooleanAuth3() throws Exception { context.turnOffAuthorisationSystem(); Collection c = createCollection(); it.setOwningCollection(c); context.restoreAuthSystemState(); doNothing().when(authorizeServiceSpy).authorizeAction(context, c, Constants.WRITE, false); assertTrue("testCanEditBooleanAuth3 0", itemService.canEdit(context, it)); }
@Test @Override public void testGetParentObject() throws SQLException { try { assertThat("testGetParentObject 0", itemService.getParentObject(context, it), notNullValue()); context.turnOffAuthorisationSystem(); Collection parent = createCollection(); it.setOwningCollection(parent); context.restoreAuthSystemState(); assertThat("testGetParentObject 1", itemService.getParentObject(context, it), notNullValue()); assertThat("testGetParentObject 2", (Collection) itemService.getParentObject(context, it), equalTo(parent)); } catch (AuthorizeException ex) { throw new AssertionError("Authorize Exception occurred", ex); } }