OaiPmhRepository { public XmlGen selectVerb(Params p) { if (p.isVerbListIdentifiers()) { return handleListIdentifiers(p); } else if (p.isVerbListRecords()) { return handleListRecords(p); } else if (p.isVerbGetRecord()) { return handleGetRecord(p); } else if (p.isVerbIdentify()) { return handleIdentify(p); } else if (p.isVerbListMetadataFormats()) { return handleListMetadataFormats(p); } else if (p.isVerbListSets()) { return handleListSets(p); } else { return createErrorResponse( "badVerb", Option.<String>none(), p.getRepositoryUrl(), "Illegal OAI verb or verb is missing."); } }  abstract Granularity getRepositoryTimeGranularity(); abstract String getRepositoryName(); abstract String getRepositoryId(); abstract OaiPmhDatabase getPersistence(); abstract String getAdminEmail(); abstract String saveQuery(ResumableQuery query); abstract Option<ResumableQuery> getSavedQuery(String resumptionToken); abstract int getResultLimit(); abstract List<MetadataProvider> getRepositoryMetadataProviders(); Date currentDate(); final List<MetadataProvider> getMetadataProviders(); void addItem(MediaPackage mp); XmlGen selectVerb(Params p); Option<MetadataProvider> getMetadataProvider(final String metadataPrefix); static Date granulate(Granularity g, Date d);  }
@Test public void testVerbIdentify() throws Exception { final OaiPmhRepository repo = repo(null, Granularity.DAY); runChecks(OaiPmhConstants.VERB_IDENTIFY, repo.selectVerb(params("Identify", null, null, null, null, null)), some(IsValid), list(hasXPath(" }
@Test public void testVerbListIdentifiersBadArgument() throws Exception { final OaiPmhRepository repo = repo(null, Granularity.DAY); runChecks(OaiPmhConstants.VERB_LIST_IDENTIFIERS, repo.selectVerb(params("ListIdentifiers", null, null, null, null, null)), some(IsError), list(hasXPath(" }
@Test @SuppressWarnings("unchecked") public void testVerbListIdentifiersAll() throws Exception { final OaiPmhRepository repo = repo( oaiPmhPersistenceMock(searchResultItem("id-1", new Date(), false), searchResultItem("id-2", utcDate(2011, 6, 1), false)), Granularity.DAY); runChecks(OaiPmhConstants.VERB_LIST_IDENTIFIERS, repo.selectVerb(params("ListIdentifiers", null, "oai_dc", null, null, null)), some(IsValid), list(hasXPath(" hasXPath(" hasXPath(" hasXPath("count( }
@Test public void testVerbListIdentifiersDateRangeError() throws Exception { runChecks(OaiPmhConstants.VERB_LIST_IDENTIFIERS, repo(null, Granularity.DAY) .selectVerb(params("ListIdentifiers", null, "oai_dc", "2011-01-02", "2011-01-01", null)), some(IsError), list(hasXPath(" runChecks(OaiPmhConstants.VERB_LIST_IDENTIFIERS, repo(null, Granularity.SECOND) .selectVerb(params("ListIdentifiers", null, "oai_dc", "2011-01-01T10:20:10Z", "2011-01-01T10:20:00Z", null)), some(IsError), list(hasXPath(" }
@Test @SuppressWarnings("unchecked") public void testVerbListRecordsAll() throws Exception { runChecks(OaiPmhConstants.VERB_LIST_RECORDS, repo(oaiPmhPersistenceMock(searchResultItem("id-1", utcDate(2011, 5, 1), false), searchResultItem("id-2", utcDate(2011, 6, 1), true)), Granularity.DAY) .selectVerb(params("ListRecords", null, "oai_dc", null, null, null)), some(IsValid), list(hasXPath(" hasXPath(" hasXPath(" hasXPath(" hasXPath(" hasXPath("count( hasXPath("count( }
@Test @SuppressWarnings("unchecked") public void testVerbGetRecord() throws Exception { runChecks(OaiPmhConstants.VERB_GET_RECORD, repo(oaiPmhPersistenceMock(searchResultItem("id-1", utcDate(2011, 6, 1), false)), Granularity.DAY) .selectVerb(params("GetRecord", "id-1", "oai_dc", null, null, null)), Option.<OaiPmhResponseStatus>none(), list(hasXPath(" hasXPath(" hasXPath(" hasXPath("count( hasXPath("count( }
@Test @SuppressWarnings("unchecked") public void testVerbGetRecordDeleted() throws Exception { runChecks(OaiPmhConstants.VERB_GET_RECORD, repo(oaiPmhPersistenceMock(searchResultItem("id-1", utcDate(2011, 5, 1), true)), Granularity.DAY) .selectVerb(params("GetRecord", "id-1", "oai_dc", null, null, null)), Option.<OaiPmhResponseStatus>none(), list(hasXPath(" hasXPath(" hasXPath(" hasXPath("count( hasXPath("count( }
@Test public void testMatterhornInlinedMetadataProvider() throws Exception { runChecks(OaiPmhConstants.VERB_LIST_RECORDS, repo(oaiPmhPersistenceMock(searchResultItem("id-1", utcDate(2011, 5, 1), false), searchResultItem("id-2", utcDate(2011, 6, 1), true)), Granularity.DAY) .selectVerb(params("ListRecords", null, "matterhorn-inlined", null, null, null)), some(IsValid), list(hasXPath(" hasXPath(" hasXPath(" hasXPath(" hasXPath(" hasXPath(" hasXPath("count( hasXPath("count( hasXPath("count( }