Item extends DSpaceObject implements DSpaceObjectLegacySupport { @Override public String getName() { return getItemService().getMetadataFirstValue(this, MetadataSchema.DC_SCHEMA, "title", null, Item.ANY); } 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 testItemFind() throws Exception { UUID id = it.getID(); Item found = itemService.find(context, id); assertThat("testItemFind 0", found, notNullValue()); assertThat("testItemFind 1", found.getID(), equalTo(id)); assertThat("testItemFind 2", found.getName(), nullValue()); }
@Test public void testCreate() throws Exception { new NonStrictExpectations(authorizeService.getClass()) {{ authorizeService.authorizeAction((Context) any, (Collection) any, Constants.ADD); result = null; authorizeService.authorizeAction((Context) any, (Collection) any, Constants.WRITE); result = null; }}; Item created = createItem(); assertThat("testCreate 0", created, notNullValue()); assertThat("testCreate 1", created.getName(), nullValue()); }
@Test public void testAddMetadata_5args_1() throws SQLException { String schema = "dc"; String element = "contributor"; String qualifier = "author"; String lang = Item.ANY; String[] values = {"value0","value1"}; itemService.addMetadata(context, it, schema, element, qualifier, lang, Arrays.asList(values)); List<MetadataValue> dc = itemService.getMetadata(it, schema, element, qualifier, lang); assertThat("testAddMetadata_5args_1 0",dc,notNullValue()); assertTrue("testAddMetadata_5args_1 1",dc.size() == 2); assertThat("testAddMetadata_5args_1 2",dc.get(0).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_5args_1 3",dc.get(0).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_5args_1 4",dc.get(0).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_5args_1 5",dc.get(0).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_5args_1 6",dc.get(0).getValue(),equalTo(values[0])); assertThat("testAddMetadata_5args_1 7",dc.get(1).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_5args_1 8",dc.get(1).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_5args_1 9",dc.get(1).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_5args_1 10",dc.get(1).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_5args_1 11",dc.get(1).getValue(),equalTo(values[1])); }
@Test public void testAddMetadata_7args_1_authority() throws InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException, SQLException { String schema = "dc"; String element = "language"; String qualifier = "iso"; String lang = Item.ANY; List<String> values = Arrays.asList("en_US","en"); List<String> authorities = Arrays.asList("accepted","uncertain"); List<Integer> confidences = Arrays.asList(0,0); itemService.addMetadata(context, it, schema, element, qualifier, lang, values, authorities, confidences); List<MetadataValue> dc = itemService.getMetadata(it, schema, element, qualifier, lang); assertThat("testAddMetadata_7args_1 0",dc,notNullValue()); assertTrue("testAddMetadata_7args_1 1",dc.size() == 2); assertThat("testAddMetadata_7args_1 2",dc.get(0).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_7args_1 3",dc.get(0).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_7args_1 4",dc.get(0).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_7args_1 5",dc.get(0).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_7args_1 6",dc.get(0).getValue(),equalTo(values.get(0))); assertThat("testAddMetadata_7args_1 7",dc.get(0).getAuthority(),equalTo(authorities.get(0))); assertThat("testAddMetadata_7args_1 8",dc.get(0).getConfidence(),equalTo(confidences.get(0))); assertThat("testAddMetadata_7args_1 9",dc.get(1).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_7args_1 10",dc.get(1).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_7args_1 11",dc.get(1).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_7args_1 12",dc.get(1).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_7args_1 13",dc.get(1).getValue(),equalTo(values.get(1))); assertThat("testAddMetadata_7args_1 14",dc.get(1).getAuthority(),equalTo(authorities.get(1))); assertThat("testAddMetadata_7args_1 15",dc.get(1).getConfidence(),equalTo(confidences.get(1))); }
@Test public void testAddMetadata_7args_1_noauthority() throws SQLException { String schema = "dc"; String element = "contributor"; String qualifier = "author"; String lang = Item.ANY; List<String> values = Arrays.asList("value0","value1"); List<String> authorities = Arrays.asList("auth0","auth2"); List<Integer> confidences = Arrays.asList(0,0); itemService.addMetadata(context, it, schema, element, qualifier, lang, values, authorities, confidences); List<MetadataValue> dc = itemService.getMetadata(it, schema, element, qualifier, lang); assertThat("testAddMetadata_7args_1 0",dc,notNullValue()); assertTrue("testAddMetadata_7args_1 1",dc.size() == 2); assertThat("testAddMetadata_7args_1 2",dc.get(0).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_7args_1 3",dc.get(0).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_7args_1 4",dc.get(0).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_7args_1 5",dc.get(0).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_7args_1 6",dc.get(0).getValue(),equalTo(values.get(0))); assertThat("testAddMetadata_7args_1 7",dc.get(0).getAuthority(),nullValue()); assertThat("testAddMetadata_7args_1 8",dc.get(0).getConfidence(),equalTo(-1)); assertThat("testAddMetadata_7args_1 9",dc.get(1).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_7args_1 10",dc.get(1).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_7args_1 11",dc.get(1).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_7args_1 12",dc.get(1).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_7args_1 13",dc.get(1).getValue(),equalTo(values.get(1))); assertThat("testAddMetadata_7args_1 14",dc.get(1).getAuthority(),nullValue()); assertThat("testAddMetadata_7args_1 15",dc.get(1).getConfidence(),equalTo(-1)); }
@Test public void testAddMetadata_5args_2() throws SQLException { String schema = "dc"; String element = "contributor"; String qualifier = "author"; String lang = Item.ANY; List<String> values = Arrays.asList("value0","value1"); itemService.addMetadata(context, it, schema, element, qualifier, lang, values); List<MetadataValue> dc = itemService.getMetadata(it, schema, element, qualifier, lang); assertThat("testAddMetadata_5args_2 0",dc,notNullValue()); assertTrue("testAddMetadata_5args_2 1",dc.size() == 2); assertThat("testAddMetadata_5args_2 2",dc.get(0).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_5args_2 3",dc.get(0).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_5args_2 4",dc.get(0).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_5args_2 5",dc.get(0).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_5args_2 6",dc.get(0).getValue(),equalTo(values.get(0))); assertThat("testAddMetadata_5args_2 7",dc.get(1).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_5args_2 8",dc.get(1).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_5args_2 9",dc.get(1).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_5args_2 10",dc.get(1).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_5args_2 11",dc.get(1).getValue(),equalTo(values.get(1))); }
@Test public void testAddMetadata_7args_2_authority() throws SQLException { String schema = "dc"; String element = "language"; String qualifier = "iso"; String lang = Item.ANY; String values = "en"; String authorities = "accepted"; int confidences = 0; itemService.addMetadata(context, it, schema, element, qualifier, lang, values, authorities, confidences); List<MetadataValue> dc = itemService.getMetadata(it, schema, element, qualifier, lang); assertThat("testAddMetadata_7args_2 0",dc,notNullValue()); assertTrue("testAddMetadata_7args_2 1",dc.size() == 1); assertThat("testAddMetadata_7args_2 2",dc.get(0).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_7args_2 3",dc.get(0).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_7args_2 4",dc.get(0).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_7args_2 5",dc.get(0).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_7args_2 6",dc.get(0).getValue(),equalTo(values)); assertThat("testAddMetadata_7args_2 7",dc.get(0).getAuthority(),equalTo(authorities)); assertThat("testAddMetadata_7args_2 8", dc.get(0).getConfidence(), equalTo(confidences)); }
@Test public void testAddMetadata_7args_2_noauthority() throws SQLException { String schema = "dc"; String element = "contributor"; String qualifier = "author"; String lang = Item.ANY; String values = "value0"; String authorities = "auth0"; int confidences = 0; itemService.addMetadata(context, it, schema, element, qualifier, lang, values, authorities, confidences); List<MetadataValue> dc = itemService.getMetadata(it, schema, element, qualifier, lang); assertThat("testAddMetadata_7args_2 0",dc,notNullValue()); assertTrue("testAddMetadata_7args_2 1",dc.size() == 1); assertThat("testAddMetadata_7args_2 2",dc.get(0).getMetadataField().getMetadataSchema().getName(),equalTo(schema)); assertThat("testAddMetadata_7args_2 3",dc.get(0).getMetadataField().getElement(),equalTo(element)); assertThat("testAddMetadata_7args_2 4",dc.get(0).getMetadataField().getQualifier(),equalTo(qualifier)); assertThat("testAddMetadata_7args_2 5",dc.get(0).getLanguage(),equalTo(lang)); assertThat("testAddMetadata_7args_2 6",dc.get(0).getValue(),equalTo(values)); assertThat("testAddMetadata_7args_2 7",dc.get(0).getAuthority(),nullValue()); assertThat("testAddMetadata_7args_2 8",dc.get(0).getConfidence(),equalTo(-1)); }
@Override @Test public void testGetName() { assertThat("testGetName 0",it.getName(),nullValue()); }