src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
DataSetsResource { @PreAuthorize("isAuthenticated()") @PostMapping public ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description) throws ProviderNotExistsException, DataSetAlreadyExist...
@Test public void shouldNotCreateTwoDatasetsWithSameId() throws Exception { Mockito.doReturn(new DataProvider()).when(uisHandler) .getProvider("provId"); String dataSetId = "dataset"; dataSetService.createDataSet("provId", dataSetId, ""); ResultActions createResponse = mockMvc.perform(post(dataSetsWebTarget, "provId") ...
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVar...
@Test @Parameters(method = "mimeTypes") public void getRepresentationByRevisionResponse(MediaType mediaType) throws Exception { RepresentationRevisionResponse representationRevisionResponse = new RepresentationRevisionResponse(representationResponse); ArrayList<File> files = new ArrayList<>(1); files.add(new File("1.xm...
RepresentationResource { @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")...
@Test @Parameters(method = "mimeTypes") public void getRepresentation(MediaType mediaType) throws Exception { Representation expected = new Representation(representation); expected.setUri(URITools.getVersionUri(getBaseUri(), globalId, schema, version)); expected.setAllVersionsUri(URITools.getAllVersionsUri(getBaseUri()...
RepresentationResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representat...
@Test public void deleteRecord() throws Exception { mockMvc.perform(delete(URITools.getRepresentationPath(globalId, schema))) .andExpect(status().isNoContent()); verify(recordService, times(1)).deleteRepresentation(globalId, schema); verifyNoMoreInteractions(recordService); } @Test @Parameters(method = "representationE...
RepresentationResource { @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String provider...
@Test public void createRepresentation() throws Exception { when(recordService.createRepresentation(globalId, schema, providerID)).thenReturn( new Representation(representation)); mockMvc.perform(post(URITools.getRepresentationPath(globalId, schema)) .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param(ParamConst...
CSVReader implements RevisionsReader { @Override public List<RevisionInformation> getRevisionsInformation(String filePath) throws IOException { List<RevisionInformation> revisionInformationList = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { String line = ""; br.readLine();...
@Test public void shouldReadAndReturnTaskIdsForCSVFile() throws IOException { List<RevisionInformation> taskIds = csvReader.getRevisionsInformation(Paths.get("src/test/resources/revisions.csv").toString()); assertNotNull(taskIds); assertEquals(8, taskIds.size()); }
RepresentationsResource { @GetMapping(produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ResponseBody public RepresentationsListWrapper getRepresentations( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { List<Representation> representationInfos = ...
@Test @Parameters(method = "mimeTypes") public void getRepresentations(MediaType mediaType) throws Exception { Record expected = new Record(record); Representation expectedRepresentation = expected.getRepresentations().get(0); expectedRepresentation.setUri(URITools.getVersionUri(getBaseUri(), globalId, schema, version)...
ContentStreamDetector { public static MediaType detectMediaType(InputStream inputStream) throws IOException { if (!inputStream.markSupported()) { throw new UnsupportedOperationException("InputStream marking support is required!"); } return new AutoDetectParser().getDetector().detect(inputStream, new Metadata()); } priv...
@Test @Parameters({ "example_metadata.xml, application/xml", "example_jpg2000.jp2, image/jp2" }) public void shouldProperlyGuessMimeType_Xml(String fileName, String expectedMimeType) throws IOException { URL resource = Resources.getResource(fileName); byte[] expected = Resources.toByteArray(resource); BufferedInputStre...
StorageSelector { public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); } StorageSelector(final PreBufferedInputStream inputStream, final String userMediaType); Storage selectStorage(); }
@Test @Parameters({ "example_metadata.xml, DATA_BASE, application/xml", "example_jpg2000.jp2, OBJECT_STORAGE, image/jp2" }) public void shouldDetectStorage(String fileName, String expectedDecision, String mediaType) throws IOException { URL resource = Resources.getResource(fileName); byte[] expected = Resources.toByteA...
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avai...
@Test @Parameters({ "10, 20", "20, 10", "10, 10000", "10000, 20", "10000, 3000", "10000, 4000", "10, 20", "20, 10" }) public void shouldProperlyCheckAvailableForByteArrayInputStream(int size, int bufferSize) throws IOException { byte[] expected = Helper.generateRandom(size); ByteArrayInputStream inputStream = new ByteA...
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int read() throws IOException { ensureIsNotClosed(); if (position < bufferFill) { return buffer[position++] & 0xff; } return super.read(); } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(f...
@Test @Parameters({ "10, 20", "200, 10", "100, 10000", "100, 200", "200, 100" }) public void shouldReadStreamPerByte(int size, int bufferSize) throws IOException { byte[] randomByes = Helper.generateSeq(size); ByteArrayInputStream inputStream = new ByteArrayInputStream(randomByes); PreBufferedInputStream instance = new...
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized void close() throws IOException { if (in == null && buffer == null) { return; } buffer = null; in.close(); in = null; } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(final byte[] data, ...
@Test public void shouldCloseClosedStream() throws IOException { PreBufferedInputStream instance = new PreBufferedInputStream(new NullInputStream(1), 1); instance.close(); instance.close(); }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException();...
@Test public void shouldCreateDataSet() throws Exception { makeUISProviderSuccess(); String dsName = "ds"; String description = "description of data set"; DataSet ds = cassandraDataSetService.createDataSet(PROVIDER_ID, dsName, description); assertThat(ds.getId(), is(dsName)); assertThat(ds.getDescription(), is(descript...
CassandraDataSetService implements DataSetService { @Override public void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version) throws DataSetNotExistsException, RepresentationNotExistsException { checkIfDatasetExists(dataSetId, providerId); Representation rep = getRepresent...
@Test(expected = DataSetNotExistsException.class) public void shouldNotAssignToNotExistingDataSet() throws Exception { makeUISProviderSuccess(); Representation r = insertDummyPersistentRepresentation("cloud-id", "schema", PROVIDER_ID); cassandraDataSetService.addAssignment(PROVIDER_ID, "not-existing", r.getCloudId(), r...
CassandraDataSetService implements DataSetService { @Override public void deleteDataSet(String providerId, String dataSetId) throws DataSetNotExistsException { checkIfDatasetExists(dataSetId, providerId); String nextToken = null; int maxSize = 10000; List<Properties> representations = dataSetDAO.listDataSet(providerId,...
@Test(expected = DataSetNotExistsException.class) public void shouldThrowExceptionWhenDeletingNotExistingDataSet() throws Exception { cassandraDataSetService.deleteDataSet("xxx", "xxx"); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, Data...
@Test(expected = DataSetNotExistsException.class) public void shouldThrowExceptionWhenRequestingCloudIdsForNonExistingDataSet() throws Exception { makeUISProviderExistsSuccess(); cassandraDataSetService.getDataSetCloudIdsByRepresentationPublished("non-existent-ds", "provider", "representation", new Date(), null, 1); } ...
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOf...
@Test public void shouldReturnTheLatestCloudIdsAndTimeStampInsideRevisionDataSet() throws Exception { int size = 10; prepareTestForTheLatestCloudIdAndTimeStampInsideDataSet(size); ResultSlice<CloudIdAndTimestampResponse> cloudIdsAndTimestampResponseResultSlice = cassandraDataSetService.getLatestDataSetCloudIdByRepresen...
CassandraDataSetService implements DataSetService { @Override public void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp) throws RepresentationNotExistsException { checkIfRepresentationExists(representationName, version, c...
@Test(expected = RepresentationNotExistsException.class) public void shouldThrowRepresentationNotExistsException() throws Exception { makeUISProviderSuccess(); makeUISSuccess(); makeDatasetExists(); Date date = new Date(); String cloudId = "2EEN23VWNXOW7LGLM6SKTDOZUBUOTKEWZ3IULSYEWEMERHISS6XA"; cassandraDataSetService....
DynamicContentDAO { public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); } @Autowired DynamicContentDAO(Map<Storage,ContentDAO> contentDAOs); void copyContent(String sourceObjectId, String trgObjectId, Storage stored); void deleteCont...
@Test(expected = ContentDaoNotFoundException.class) public void shouldThrowExceptionOnNonExistingDAO() throws FileNotExistsException { final DynamicContentDAO instance = new DynamicContentDAO(prepareDAOMap( mock(SwiftContentDAO.class) )); instance.deleteContent("exampleFileName",Storage.DATA_BASE); } @Test public void ...
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(provide...
@Test(expected = RecordNotExistsException.class) public void shouldThrowExpWhileCreatingRepresentationIfNoRecordInUis() throws Exception { makeUISThrowRecordNotExist(); mockUISProvider1Success(); cassandraRecordService.createRepresentation("globalId", "dc", PROVIDER_1_ID); } @Test(expected = SystemException.class) publ...
CassandraRecordService implements RecordService { @Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); }...
@Test(expected = RecordNotExistsException.class) public void shouldThrowExpWhileGettingRecordIfNoRecordInUis() throws Exception { makeUISThrowRecordNotExist(); cassandraRecordService.getRecord("globalId"); } @Test(expected = SystemException.class) public void shouldThrowSystemExpWhileGettingRecordIfUisFails() throws Ex...
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRe...
@Test(expected = RecordNotExistsException.class) public void shouldThrowExpWhileDeletingRecordIfNoRecordInUis() throws Exception { makeUISThrowRecordNotExist(); cassandraRecordService.deleteRecord("globalId"); } @Test(expected = SystemException.class) public void shouldThrowSystemExpWhileDeletingRecordIfUisFails() thro...
CassandraRecordService implements RecordService { @Override public Representation getRepresentation(String globalId, String schema) throws RepresentationNotExistsException { Representation rep = recordDAO.getLatestPersistentRepresentation(globalId, schema); if (rep == null) { throw new RepresentationNotExistsException(...
@Test(expected = RepresentationNotExistsException.class) public void shouldThrowRepresentationNotFoundExpWhenNoSuchRepresentation() throws Exception { makeUISSuccess(); cassandraRecordService.getRepresentation("globalId", "not_existing_schema"); }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } @Override String nameConversion(final String s); }
@Test public void shouldRetrunNullString() { final String fileName = ""; final String output = migrator.nameConversion(fileName); assertEquals(null, output); } @Test public void shouldConvertFileProperly() { final String fileName = "test2|test1|tes2"; final String output = migrator.nameConversion(fileName); assertEqual...
CassandraRecordService implements RecordService { @Override public void deleteRepresentation(String globalId, String schema) throws RepresentationNotExistsException { List<Representation> listRepresentations = recordDAO.listRepresentationVersions(globalId, schema); sortByProviderId(listRepresentations); String dPId = n...
@Test public void shouldDeletePersistentRepresentation() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = insertDummyPersistentRepresentation("globalId", "dc", PROVIDER_1_ID); cassandraRecordService.deleteRepresentation(r.getCloudId(), r.getRepresentationName(), r.getVersion()); }
CassandraRecordService implements RecordService { @Override public boolean putContent(String globalId, String schema, String version, File file, InputStream content) throws CannotModifyPersistentRepresentationException, RepresentationNotExistsException { DateTime now = new DateTime(); Representation representation = ge...
@Test(expected = CannotModifyPersistentRepresentationException.class) public void shouldNotAddFileToPersistentRepresentation() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = insertDummyPersistentRepresentation("globalId", "dc", PROVIDER_1_ID); byte[] dummyContent = {1, 2, 3}; File f ...
CassandraRecordService implements RecordService { @Override public void deleteContent(String globalId, String schema, String version, String fileName) throws FileNotExistsException, CannotModifyPersistentRepresentationException, RepresentationNotExistsException { Representation representation = getRepresentation(global...
@Test(expected = CannotModifyPersistentRepresentationException.class) public void shouldNotRemoveFileFromPersistentRepresentation() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = insertDummyPersistentRepresentation("globalId", "dc", PROVIDER_1_ID); File f = r.getFiles().get(0); cassa...
CassandraRecordService implements RecordService { @Override public void addRevision(String globalId, String schema, String version, Revision revision) throws RevisionIsNotValidException { recordDAO.addOrReplaceRevisionInRepresentation(globalId, schema, version, revision); } @Override Record getRecord(String cloudId); ...
@Test public void addRevision() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = cassandraRecordService.createRepresentation( "globalId", "edm", PROVIDER_1_ID); Revision revision = new Revision(REVISION_NAME, REVISION_PROVIDER); cassandraRecordService.addRevision(r.getCloudId(), r.getR...
CassandraRecordService implements RecordService { @Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : re...
@Test public void getRevision() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = cassandraRecordService.createRepresentation( "globalId", "edm", PROVIDER_1_ID); Revision revision = new Revision(REVISION_NAME, REVISION_PROVIDER, new Date(), true, false, true); cassandraRecordService.add...
InMemoryDataSetService implements DataSetService { @Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representa...
@Test @Parameters(method = "listDatasetParams") public void shouldListDataSet(String threshold, int limit, String nextSlice, int fromIndex, int toIndex) throws Exception { ResultSlice<Representation> actual = dataSetService.listDataSet(providerId, dataSetId, threshold, limit); assertThat("Next slice should be equal '" ...
InMemoryRecordService implements RecordService { public ResultSlice<Representation> search(RepresentationSearchParams searchParams, String thresholdParam, int limit) { int threshold = 0; if (thresholdParam != null) { threshold = parseInteger(thresholdParam); } String providerId = searchParams.getDataProvider(); String ...
@Test @Parameters(method = "searchRepresentatonsParams") public void shouldSearchRepresentations(String threshold, int limit, int fromIndex, int toIndex, String nextSlice) { List<Representation> representations = createRepresentations(5, PROVIDER_ID, SCHEMA); when(recordDAO.findRepresentations(PROVIDER_ID, SCHEMA)).the...
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryP...
@Betamax(tape = "dataSets_shouldRetrieveDataSetsFirstChunk") @Test public void shouldRetrieveDataSetsFirstChunk() throws MCSException { String providerId = "Provider002"; int resultSize = 100; String startFrom = "dataset000101"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); ResultSlice<DataSet> res...
DataSetServiceClient extends MCSClient { public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || ...
@Betamax(tape = "dataSets_shouldReturnAllDataSets") @Test public void shouldReturnAllDataSets() throws MCSException { String providerId = "Provider002"; int resultSize = 200; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); List<DataSet> result = instance.getDataSetsForProvider(providerId); assertNotN...
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASE...
@Betamax(tape = "dataSets_shouldSuccessfullyCreateDataSet") @Test public void shouldSuccessfullyCreateDataSet() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000008"; String description = "description01"; String expectedLocation = baseUrl + "/data-providers/" + providerId + "/data-...
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DAT...
@Betamax(tape = "dataSets_shouldRetrieveRepresentationsFirstChunk") @Test public void shouldRetrieveRepresentationsFirstChunk() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000002"; int resultSize = 100; String startFrom = "G5DFUSCILJFVGQSEJYFHGY3IMVWWCMI="; DataSetServiceClient i...
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChu...
@Betamax(tape = "dataSets_shouldReturnAllRepresentations") @Test public void shouldReturnAllRepresentations() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000002"; int resultSize = 200; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); List<Representation> result ...
DataSetServiceClient extends MCSClient { public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form...
@Betamax(tape = "dataSets_shouldThrowDataSetNotExistsForUpdateDescription") @Test(expected = DataSetNotExistsException.class) public void shouldThrowDataSetNotExistsForUpdateDescription() throws MCSException { String providerId = "Provider002"; String dataSetId = "noSuchDataset"; String description = "TEST4"; DataSetSe...
Elasticsearch implements Indexer { @Override public SearchResult search(String text, String[] fields) throws ConnectionException, IndexerException { return search(text, fields, PAGE_SIZE, 0); } Elasticsearch(IndexerInformations ii); Elasticsearch(String clasterAddresses, String index, String type); protected Elastics...
@Test public void searchTest() throws IndexerException { boolean ok = false; int i = 0; do { try { createIndex("test"); client().prepareIndex("test", "type", "1").setSource("field1", "value1").execute().actionGet(); client().prepareIndex("test", "type", "2").setSource("field1", "value2").execute().actionGet(); client()...
DataSetServiceClient extends MCSClient { public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { respo...
@Betamax(tape = "dataSets_shouldThrowDataSetNotExistsForDeleteDataSet") @Test(expected = DataSetNotExistsException.class) public void shouldThrowDataSetNotExistsForDeleteDataSet() throws MCSException { String providerId = "Provider002"; String dataSetId = "dataset000033"; DataSet dataSet = new DataSet(); dataSet.setPro...
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) ...
@Betamax(tape = "dataSets_shouldAssignRepresentation") @Test public void shouldAssignRepresentation() throws MCSException { String providerId = "Provider002"; String dataSetId = "dataset000008"; String cloudId = "1DZ6HTS415W"; String representationName = "schema66"; String versionId = "b95fcda0-994a-11e3-bfe1-1c6f653f6...
DataSetServiceClient extends MCSClient { public void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, provider...
@Betamax(tape = "dataSets_shouldUnassignRepresentation") @Test public void shouldUnassignRepresentation() throws MCSException { String providerId = "Provider002"; String dataSetId = "dataset000002"; String cloudId = "1DZ6HTS415W"; String representationName = "schema66"; String representationVersion = "66404040-0307-11e...
Elasticsearch implements Indexer { @Override public SearchResult getMoreLikeThis(String documentId) throws ConnectionException, IndexerException { return getMoreLikeThis(documentId, null, MAX_QUERY_TERMS, MIN_TERM_FREQ, MIN_DOC_FREQ, MAX_DOC_FREQ, MIN_WORD_LENGTH, MAX_WORD_LENGTH, PAGE_SIZE, 0, false); } Elasticsearch(...
@Test public void moreLikeThisTest() throws IndexerException, IOException { boolean ok = false; int i = 0; do { try { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") .startObject("field3").field("type", "string").field("term_vector", "yes") .endObject...
DataSetServiceClient extends MCSClient { public DataSetIterator getDataSetIteratorForProvider(String providerId) { return new DataSetIterator(this, providerId); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String u...
@Betamax(tape = "dataSets_shouldProvideDataSetIterator") @Test public void shouldProvideDataSetIterator() throws MCSException { String providerId = "Provider001"; int numberOfDataSets = 200; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); DataSetIterator iterator = instance.getDataSetIteratorForProvi...
DataSetServiceClient extends MCSClient { public RepresentationIterator getRepresentationIterator(String providerId, String dataSetId) { return new RepresentationIterator(this, providerId, dataSetId); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServi...
@Betamax(tape = "dataSets_shouldProvideRepresentationIterator") @Test public void shouldProvideRepresentationIterator() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset3"; int numberOfRepresentations = 200; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); Representa...
AuthenticationResource { @PostMapping(value = "/create-user", produces = {MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE}) @PreAuthorize("hasRole('ROLE_ADMIN')") public ResponseEntity<String> createCloudUser( @RequestParam(AASParamConstants.P_USER_NAME) String username, @RequestParam(AASParamConstant...
@Test public void testCreateCloudUser() throws Exception { Mockito.doReturn(new User(username, password)).when(authenticationService).getUser(username); mockMvc.perform(post("/create-user") .param(AASParamConstants.P_USER_NAME, username) .param(AASParamConstants.P_PASS_TOKEN, password)) .andExpect(status().isOk()); }
DataSetServiceClient extends MCSClient { public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DAT...
@Betamax(tape = "dataSets_shouldRetrieveDataSetCloudIdsByRepresentationFirstChunk") @Test public void shouldRetrieveDataSetCloudIdsByRepresentationFirstChunk() throws MCSException { String providerId = "provider"; String dataSet = "dataset"; String representationName = "representation"; String dateFrom = "2016-08-21T11...
DataSetServiceClient extends MCSClient { public List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp) throws MCSException { List<CloudTagsResponse> resultList = new ArrayList<>(); ResultSlice...
@Betamax(tape = "dataSets_shouldRetrieveCloudIdsForSpecificRevision") @Test public void shouldRetrieveCloudIdsForSpecificRevision() throws MCSException { String providerId = "LFT"; String dataSetId = "set1"; String representationName = "t1"; String revisionName = "IMPORT"; String revisionProviderId = "EU"; String revis...
DataSetServiceClient extends MCSClient { public ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit) throws MCSException { WebTarget target = cli...
@Betamax(tape = "dataSets_shouldRetrievCloudIdsChunkForSpecificRevision") @Test public void shouldRetrievCloudIdsChunkForSpecificRevision() throws MCSException { String providerId = "LFT"; String dataSetId = "set1"; String representationName = "t1"; String revisionName = "IMPORT"; String revisionProviderId = "EU"; Stri...
DataSetServiceClient extends MCSClient { public String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_LATELY_REVISIONED_VERSION) ....
@Betamax(tape = "dataSets_shouldRetrieveLatelyTaggedRecordsVersion") @Test public void shouldReturnSpecificVersion() throws MCSException { String providerId = "provider"; String dataSetId = "dataset"; String cloudId = "cloudId"; String representationName = "representation"; String revisionName = "revision"; String revi...
MCSExceptionProvider { public static MCSException generateException(ErrorInfo errorInfo) { if (errorInfo == null) { throw new DriverException("Null errorInfo passed to generating exception."); } McsErrorCode errorCode; try { errorCode = McsErrorCode.valueOf(errorInfo.getErrorCode()); } catch (IllegalArgumentException e...
@Test(expected = DriverException.class) public void shouldThrowDriverExceptionWhenNullErrorInfoPassed() { ErrorInfo errorInfo = null; MCSExceptionProvider.generateException(errorInfo); } @Test(expected = DriverException.class) public void shouldThrowDriverExceptionWhenUnknownErrorInfoCodePassed() { ErrorInfo errorInfo ...
CassandraAuthenticationService implements UserDetailsService, AuthenticationService { @Override public User getUser(String userName) throws DatabaseConnectionException, UserDoesNotExistException { return userDao.getUser(userName); } CassandraAuthenticationService(); CassandraAuthenticationService(CassandraUserDAO user...
@Test(expected = UserDoesNotExistException.class) public void testUserDoesNotExist() throws Exception { service.getUser("test2"); }
FileServiceClient extends MCSClient { public InputStream getFile(String cloudId, String representationName, String version, String fileName) throws MCSException, IOException { WebTarget target = client .target(baseUrl) .path(FILE_RESOURCE) .resolveTemplate(CLOUD_ID, cloudId) .resolveTemplate(REPRESENTATION_NAME, repres...
@Betamax(tape = "files/shouldGetFileWithoutRange") @Test public void shouldGetFileWithoutRange() throws UnsupportedEncodingException, MCSException, IOException { byte[] contentBytes = MODIFIED_FILE_CONTENTS.getBytes("UTF-8"); String contentChecksum = Hashing.md5().hashBytes(contentBytes).toString(); FileServiceClient i...
CassandraAuthenticationService implements UserDetailsService, AuthenticationService { @Override public void deleteUser(final String userName) throws DatabaseConnectionException, UserDoesNotExistException { userDao.deleteUser(userName); } CassandraAuthenticationService(); CassandraAuthenticationService(CassandraUserDAO...
@Test(expected = UserDoesNotExistException.class) public void testDeleteUser() throws Exception { dao.createUser(new SpringUser("test3", "test3")); service.deleteUser("test3"); service.getUser("test3"); } @Test(expected = UserDoesNotExistException.class) public void testDeleteUserException() throws Exception { service....
RemoverImpl implements Remover { @Override public void removeNotifications(long taskId) { int retries = DEFAULT_RETRIES; while (true) { try { subTaskInfoDAO.removeNotifications(taskId); break; } catch (Exception e) { if (retries-- > 0) { LOGGER.warn("Error while removing the logs. Retries left: " + retries); waitForThe...
@Test public void shouldSuccessfullyRemoveNotifications() { doNothing().when(subTaskInfoDAO).removeNotifications(eq(TASK_ID)); removerImpl.removeNotifications(TASK_ID); verify(subTaskInfoDAO, times(1)).removeNotifications((eq(TASK_ID))); } @Test(expected = Exception.class) public void shouldRetry5TimesBeforeFailing() {...
FileServiceClient extends MCSClient { public URI uploadFile(String cloudId, String representationName, String version, InputStream data, String mediaType, String expectedMd5) throws IOException, MCSException { Response response = null; FormDataMultiPart multipart = new FormDataMultiPart(); try { WebTarget target = clie...
@Betamax(tape = "files/shouldUploadFile") @Test public void shouldUploadFile() throws UnsupportedEncodingException, MCSException, IOException { String contentString = UPLOADED_FILE_CONTENTS; byte[] contentBytes = contentString.getBytes("UTF-8"); InputStream contentStream = new ByteArrayInputStream(contentBytes); String...
FileServiceClient extends MCSClient { public URI modyfiyFile(String cloudId, String representationName, String version, InputStream data, String mediaType, String fileName, String expectedMd5) throws IOException, MCSException { Response response = null; FormDataMultiPart multipart = new FormDataMultiPart(); try { WebTa...
@Betamax(tape = "files/shouldModifyFile") @Test public void shouldModifyFile() throws UnsupportedEncodingException, IOException, MCSException { String contentString = MODIFIED_FILE_CONTENTS; byte[] contentBytes = contentString.getBytes("UTF-8"); InputStream contentStream = new ByteArrayInputStream(contentBytes); String...
FileServiceClient extends MCSClient { public void deleteFile(String cloudId, String representationName, String version, String fileName) throws MCSException { WebTarget target = client .target(baseUrl) .path(FILE_RESOURCE) .resolveTemplate(CLOUD_ID, cloudId) .resolveTemplate(REPRESENTATION_NAME, representationName) .re...
@Betamax(tape = "files/shouldDeleteFile") public void shouldDeleteFile() throws MCSException { FileServiceClient instance = new FileServiceClient(baseUrl, username, password); instance.deleteFile(TEST_CLOUD_ID, TEST_REPRESENTATION_NAME, TEST_VERSION, UPLOADED_FILE_CONTENTS); Response response = BuildWebTarget(cloudId, ...
CassandraAclService implements AclService { @Override public Acl readAclById(ObjectIdentity object) throws NotFoundException { return readAclById(object, null); } CassandraAclService(AclRepository aclRepository, AclCache aclCache, PermissionGrantingStrategy grantingStrategy, AclAuthorizationStrategy aclAuth...
@Test(expected = NotFoundException.class) public void testCreateAndRetrieve() throws Exception { TestingAuthenticationToken auth = new TestingAuthenticationToken(creator, creator); auth.setAuthenticated(true); SecurityContextHolder.getContext().setAuthentication(auth); ObjectIdentity obj = new ObjectIdentityImpl(testKe...
RecordServiceClient extends MCSClient { public Record getRecord(String cloudId) throws MCSException { WebTarget target = client .target(baseUrl) .path(RECORDS_RESOURCE) .resolveTemplate(CLOUD_ID, cloudId); Builder request = target.request(); Response response = null; try { response = request.get(); if (response.getStat...
@Betamax(tape = "records_shouldRetrieveRecord") @Test public void shouldRetrieveRecord() throws MCSException { RecordServiceClient instance = new RecordServiceClient(baseUrl, username, password); Record record = instance.getRecord(CLOUD_ID); assertNotNull(record); assertEquals(CLOUD_ID, record.getCloudId()); } @Betamax...
RecordServiceClient extends MCSClient { public void deleteRecord(String cloudId) throws MCSException { WebTarget target = client .target(baseUrl) .path(RECORDS_RESOURCE) .resolveTemplate(CLOUD_ID, cloudId); Builder request = target.request(); handleDeleteRequest(request); } RecordServiceClient(String baseUrl); RecordS...
@Betamax(tape = "records_shouldThrowRecordNotExistsForDeleteRecord") @Test(expected = AccessDeniedOrObjectDoesNotExistException.class) public void shouldThrowRecordNotExistsForDeleteRecord() throws MCSException { String cloudId = "noSuchRecord"; RecordServiceClient instance = new RecordServiceClient(baseUrl, username, ...
RecordServiceClient extends MCSClient { public List<Representation> getRepresentations(String cloudId) throws MCSException { WebTarget target = client .target(baseUrl) .path(REPRESENTATIONS_RESOURCE) .resolveTemplate(CLOUD_ID, cloudId); Response response = null; try { response = target.request().get(); if (response.get...
@Betamax(tape = "records_shouldRetrieveRepresentations") @Test public void shouldRetrieveRepresentations() throws MCSException { RecordServiceClient instance = new RecordServiceClient(baseUrl, username, password); List<Representation> representationList = instance .getRepresentations(CLOUD_ID); assertNotNull(representa...
RecordServiceClient extends MCSClient { public Representation getRepresentation(String cloudId, String representationName) throws MCSException { WebTarget target = client .target(baseUrl) .path(REPRESENTATION_RESOURCE) .resolveTemplate(CLOUD_ID, cloudId) .resolveTemplate(REPRESENTATION_NAME, representationName); Builde...
@Betamax(tape = "records_shouldRetrieveLastPersistentRepresentationForRepresentationName") @Test public void shouldRetrieveLastPersistentRepresentationForRepresentationName() throws MCSException { RecordServiceClient instance = new RecordServiceClient(baseUrl, username, password); Representation representation = instan...
CassandraAclRepository implements AclRepository { @Override public Map<AclObjectIdentity, Set<AclEntry>> findAcls(List<AclObjectIdentity> objectIdsToLookup) { assertAclObjectIdentityList(objectIdsToLookup); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN findAcls: objectIdentities: " + objectIdsToLookup); } List<String> i...
@Test(expected = IllegalArgumentException.class) public void testFindAclListEmpty() { service.findAcls(new ArrayList<AclObjectIdentity>()); } @Test(expected = IllegalArgumentException.class) public void testFindNullAclList() { service.findAcls(null); }
RecordServiceClient extends MCSClient { public URI createRepresentation(String cloudId, String representationName, String providerId) throws MCSException { WebTarget target = client .target(baseUrl) .path(REPRESENTATION_RESOURCE) .resolveTemplate(CLOUD_ID, cloudId) .resolveTemplate(REPRESENTATION_NAME, representationNa...
@Betamax(tape = "records_shouldThrowRecordNotExistsForCreateRepresentation") @Test(expected = RecordNotExistsException.class) public void shouldThrowRecordNotExistsForCreateRepresentation() throws MCSException { String cloudId = "noSuchRecord"; String representationName = "schema_000001"; String providerId = "Provider0...
RecordServiceClient extends MCSClient { public void deleteRepresentation(String cloudId, String representationName) throws MCSException { WebTarget target = client .target(baseUrl) .path(REPRESENTATION_RESOURCE) .resolveTemplate(CLOUD_ID, cloudId) .resolveTemplate(REPRESENTATION_NAME, representationName); Builder reque...
@Betamax(tape = "records_shouldThrowRepresentationNotExistsForDeleteRepresentationNameWhenNoRepresentationName") @Test(expected = AccessDeniedOrObjectDoesNotExistException.class) public void shouldThrowRepresentationNotExistsForDeleteRepresentationNameWhenNoRepresentationName() throws MCSException { String cloudId = "J...
RecordServiceClient extends MCSClient { public URI copyRepresentation(String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(baseUrl) .path(REPRESENTATION_VERSION_COPY) .resolveTemplate(CLOUD_ID, cloudId) .resolveTemplate(REPRESENTATION_NAME, representationNam...
@Betamax(tape = "records_shouldThrowRepresentationNotExistsForCopyRepresentationWhenNoRecord") @Test(expected = AccessDeniedOrObjectDoesNotExistException.class) public void shouldThrowRepresentationNotExistsForCopyRepresentationWhenNoRecord() throws MCSException { String cloudId = "noSuchRecord"; String representationN...
CassandraAclRepository implements AclRepository { @Override public AclObjectIdentity findAclObjectIdentity(AclObjectIdentity objectId) { assertAclObjectIdentity(objectId); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN findAclObjectIdentity: objectIdentity: " + objectId); } Row row = session .execute(QueryBuilder.select(...
@Test(expected = IllegalArgumentException.class) public void testFindNullAcl() { service.findAclObjectIdentity(null); } @Test public void testFindAclNotExisting() { AclObjectIdentity newAoi = new AclObjectIdentity(); newAoi.setId("invalid"); newAoi.setObjectClass(aoi_class); newAoi.setOwnerId(sid1); service.findAclObje...
RecordServiceClient extends MCSClient { public URI persistRepresentation(String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(baseUrl) .path(REPRESENTATION_VERSION_PERSIST) .resolveTemplate(CLOUD_ID, cloudId) .resolveTemplate(REPRESENTATION_NAME, representat...
@Betamax(tape = "records_shouldThrowRepresentationNotExistsExceptionForPersistRepresentationWhenNoRecord") @Test(expected = AccessDeniedOrObjectDoesNotExistException.class) public void shouldThrowRepresentationNotExistsExceptionForPersistRepresentationWhenNoRecord() throws MCSException, IOException { String cloudId = "...
RecordServiceClient extends MCSClient { public void grantPermissionsToVersion(String cloudId, String representationName, String version, String userName, Permission permission) throws MCSException { WebTarget target = client .target(baseUrl) .path(REPRESENTATION_PERMISSION) .resolveTemplate(CLOUD_ID, cloudId) .resolveT...
@Test(expected = AccessDeniedOrObjectDoesNotExistException.class) @Betamax(tape = "records_shouldThrowAccessDeniedOrObjectDoesNotExistExceptionWhileTryingToUpdatePermissions") public void shouldThrowAccessDeniedOrObjectDoesNotExistExceptionWhileTryingToUpdatePermissions() throws MCSException, IOException { RecordServic...
RecordServiceClient extends MCSClient { public void revokePermissionsToVersion(String cloudId, String representationName, String version, String userName, Permission permission) throws MCSException { WebTarget target = client .target(baseUrl) .path(REPRESENTATION_PERMISSION) .resolveTemplate(CLOUD_ID, cloudId) .resolve...
@Test(expected = AccessDeniedOrObjectDoesNotExistException.class) @Betamax(tape = "records_shouldThrowAccessDeniedOrObjectDoesNotExistExceptionWhileTryingToRevokePermissions") public void shouldThrowAccessDeniedOrObjectDoesNotExistExceptionWhileTryingToRevokePermissions() throws MCSException, IOException { RecordServic...
RecordServiceClient extends MCSClient { public List<Representation> getRepresentationsByRevision( String cloudId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp) throws MCSException { WebTarget webtarget = client .target(baseUrl) .path(REPRESENTATION_REVISIONS_RESOUR...
@Betamax(tape = "records_shouldRetrieveRepresentationByRevision") @Test public void shouldRetrieveRepresentationRevision() throws MCSException { RecordServiceClient instance = new RecordServiceClient("http: List<Representation> representations = instance.getRepresentationsByRevision("Z6DX3RWCEFUUSGRUWP6QZWRIZKY7HI5Y7H4...
CassandraDataProviderService implements DataProviderService { @Override public DataProvider getProvider(String providerId) throws ProviderDoesNotExistException { LOGGER.info("getProvider() providerId='{}'", providerId); DataProvider dp = dataProviderDao.getProvider(providerId); if (dp == null) { LOGGER.warn("ProviderDo...
@Test(expected = ProviderDoesNotExistException.class) public void shouldFailWhenFetchingNonExistingProvider() throws ProviderDoesNotExistException { cassandraDataProviderService.getProvider("provident"); }
CassandraDataProviderService implements DataProviderService { @Override public ResultSlice<DataProvider> getProviders(String thresholdProviderId, int limit) { LOGGER.info("getProviders() thresholdProviderId='{}', limit='{}'", thresholdProviderId, limit); String nextProvider = null; List<DataProvider> providers = dataPr...
@Test public void shouldReturnEmptyArrayWhenNoProviderAdded() { assertTrue("Expecting no providers", cassandraDataProviderService.getProviders(null, 1).getResults().isEmpty()); }
CassandraDataProviderService implements DataProviderService { @Override public void deleteProvider(String providerId) throws ProviderDoesNotExistException { LOGGER.info("Deleting provider {}", providerId); DataProvider dp = dataProviderDao.getProvider(providerId); if (dp == null) { LOGGER.warn("ProviderDoesNotExistExce...
@Test(expected = ProviderDoesNotExistException.class) public void shouldThrowExceptionWhenDeletingNonExistingProvider() throws ProviderDoesNotExistException { cassandraDataProviderService.deleteProvider("not existing provident"); }
CassandraUniqueIdentifierService implements UniqueIdentifierService { @Override public CloudId getCloudId(String providerId, String recordId) throws DatabaseConnectionException, RecordDoesNotExistException { LOGGER.info("getCloudId() providerId='{}', recordId='{}'", providerId, recordId); List<CloudId> cloudIds = local...
@Test(expected = RecordDoesNotExistException.class) public void testRecordDoesNotExist() throws Exception { service.getCloudId("test2", "test2"); }
CassandraUniqueIdentifierService implements UniqueIdentifierService { @Override public List<CloudId> getLocalIdsByCloudId(String cloudId) throws DatabaseConnectionException, CloudIdDoesNotExistException { LOGGER.info("getLocalIdsByCloudId() cloudId='{}'", cloudId); List<CloudId> cloudIds = cloudIdDao.searchById(cloudId...
@Test(expected = CloudIdDoesNotExistException.class) public void testGetLocalIdsByCloudId() throws Exception { List<CloudId> gid = service.getLocalIdsByCloudId(IdGenerator .encodeWithSha256AndBase32("/test11/test11")); CloudId gId = service.createCloudId("test11", "test11"); gid = service.getLocalIdsByCloudId(gId.getId...
CassandraUniqueIdentifierService implements UniqueIdentifierService { @Override public List<CloudId> getCloudIdsByProvider(String providerId, String startRecordId, int limit) throws DatabaseConnectionException, ProviderDoesNotExistException { LOGGER.info("getCloudIdsByProvider() providerId='{}', startRecordId='{}', end...
@Test public void testGetCloudIdsByProvider() throws Exception { String providerId = "providerId"; dataProviderDao.createDataProvider(providerId, new DataProviderProperties()); service.createCloudId(providerId, "test3"); service.createCloudId(providerId, "test2"); List<CloudId> cIds = service .getCloudIdsByProvider(pro...
CassandraUniqueIdentifierService implements UniqueIdentifierService { @Override public CloudId createIdMapping(String cloudId, String providerId, String recordId) throws DatabaseConnectionException, CloudIdDoesNotExistException, IdHasBeenMappedException, ProviderDoesNotExistException, CloudIdAlreadyExistException { LOG...
@Test(expected = IdHasBeenMappedException.class) public void testCreateIdMapping() throws Exception { dataProviderDao.createDataProvider("test12", new DataProviderProperties()); CloudId gid = service.createCloudId("test12", "test12"); service.createIdMapping(gid.getId(), "test12", "test13"); service.createIdMapping(gid...
CassandraUniqueIdentifierService implements UniqueIdentifierService { @Override public void removeIdMapping(String providerId, String recordId) throws DatabaseConnectionException, ProviderDoesNotExistException { LOGGER.info("removeIdMapping() removing Id mapping for providerId='{}', recordId='{}' ...", providerId, reco...
@Test(expected = RecordDoesNotExistException.class) public void testRemoveIdMapping() throws Exception { dataProviderDao.createDataProvider("test16", new DataProviderProperties()); service.createCloudId("test16", "test16"); service.removeIdMapping("test16", "test16"); service.getCloudId("test16", "test16"); }
CassandraUniqueIdentifierService implements UniqueIdentifierService { @Override public List<CloudId> deleteCloudId(String cloudId) throws DatabaseConnectionException, CloudIdDoesNotExistException { LOGGER.info("deleteCloudId() deleting cloudId='{}' ...", cloudId); if (cloudIdDao.searchById(cloudId).isEmpty()) { LOGGER....
@Test(expected = RecordDoesNotExistException.class) public void testDeleteCloudId() throws Exception { dataProviderDao.createDataProvider("test21", new DataProviderProperties()); CloudId cId = service.createCloudId("test21", "test21"); service.deleteCloudId(cId.getId()); service.getCloudId(cId.getLocalId().getProviderI...
CassandraUniqueIdentifierService implements UniqueIdentifierService { @Override public CloudId createCloudId(String... recordInfo) throws DatabaseConnectionException, RecordExistsException, ProviderDoesNotExistException, CloudIdAlreadyExistException { LOGGER.info("createCloudId() creating cloudId"); String providerId =...
@Test @Ignore public void createCloudIdCollisonTest() throws DatabaseConnectionException, RecordExistsException, ProviderDoesNotExistException, RecordDatasetEmptyException, CloudIdDoesNotExistException, CloudIdAlreadyExistException { final Map<String, String> map = new HashMap<String, String>(); dataProviderDao.createD...
CassandraCloudIdDAO { public List<CloudId> insert(boolean insertOnlyIfNoExist, String... args) throws DatabaseConnectionException, CloudIdAlreadyExistException { ResultSet rs = null; try { if (insertOnlyIfNoExist) { rs = dbService.getSession().execute(insertIfNoExistsStatement.bind(args[0], args[1], args[2])); Row row ...
@Test(expected = CloudIdAlreadyExistException.class) public void insert_tryInsertTheSameContentTwice_ThrowsCloudIdAlreadyExistException() throws Exception { final String providerId = "providerId"; final String recordId = "recordId"; final String id = "id"; service.insert(true, id, providerId, recordId); service.insert(...
StaticUrlProvider implements UrlProvider { public String getBaseUrl() { return baseUrl; } StaticUrlProvider(final String serviceUrl); String getBaseUrl(); }
@Test @Parameters({"uis/,uis","uis,uis","uis public void shouldGetUrlWithoutSlashAtTheEnd(String inputSuffix, String expectedSuffix) { StaticUrlProvider provider = new StaticUrlProvider(URL_PREFIX + inputSuffix); String result = provider.getBaseUrl(); assertThat(result,is(URL_PREFIX + expectedSuffix)); }
DateAdapter extends XmlAdapter<String, Date> { @Override public Date unmarshal(String stringDate) throws ParseException { if (stringDate == null || stringDate.isEmpty()) { return null; } try { Date date = GregorianCalendar.getInstance().getTime(); if(date == null){ throw new ParseException("Cannot parse the date. The a...
@Test public void shouldSerializeTheDateSuccessfully() throws ParseException { Date date = dateAdapter.unmarshal(DATE_STRING); assertEquals(cal.getTime(), date); } @Test(expected = ParseException.class) public void shouldThrowParsingException() throws ParseException { String unParsedDateString = "2017-11-23"; dateAdapt...
DateAdapter extends XmlAdapter<String, Date> { @Override public String marshal(Date date) { if (date == null) { throw new RuntimeException("The revision creation Date shouldn't be null"); } return FORMATTER.format(date); } @Override String marshal(Date date); @Override Date unmarshal(String stringDate); }
@Test public void shouldDeSerializeTheDateSuccessfully() { assertEquals(dateAdapter.marshal(cal.getTime()), DATE_STRING); } @Test(expected = RuntimeException.class) public void shouldThrowRunTimeException() { dateAdapter.marshal(null); }
CassandraAclRepository implements AclRepository { @Override public List<AclObjectIdentity> findAclObjectIdentityChildren(AclObjectIdentity objectId) { assertAclObjectIdentity(objectId); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN findAclObjectIdentityChildren: objectIdentity: " + objectId); } ResultSet resultSet = ses...
@Test public void testFindAclChildrenForNotExistingAcl() { AclObjectIdentity newAoi = new AclObjectIdentity(); newAoi.setId("invalid"); newAoi.setObjectClass(aoi_class); newAoi.setOwnerId(sid1); List<AclObjectIdentity> children = service .findAclObjectIdentityChildren(newAoi); assertTrue(children.isEmpty()); } @Test(ex...
CassandraAclRepository implements AclRepository { @Override public void updateAcl(AclObjectIdentity aoi, List<AclEntry> entries) throws AclNotFoundException { assertAclObjectIdentity(aoi); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN updateAcl: aclObjectIdentity: " + aoi + ", entries: " + entries); } AclObjectIdentity ...
@Test(expected = IllegalArgumentException.class) public void testUpdateNullAcl() { service.updateAcl(null, null); } @Test(expected = AclNotFoundException.class) public void testUpdateAclNotExisting() { AclObjectIdentity newAoi = new AclObjectIdentity(); newAoi.setId("invalid"); newAoi.setObjectClass(aoi_class); newAoi....
CassandraAclRepository implements AclRepository { @Override public void saveAcl(AclObjectIdentity aoi) throws AclAlreadyExistsException { assertAclObjectIdentity(aoi); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN saveAcl: aclObjectIdentity: " + aoi); } if (findAclObjectIdentity(aoi) != null) { throw new AclAlreadyExist...
@Test(expected = IllegalArgumentException.class) public void testSaveNullAcl() { service.saveAcl(null); } @Test(expected = AclAlreadyExistsException.class) public void testSaveAclAlreadyExisting() { AclObjectIdentity newAoi = createDefaultTestAOI(); service.saveAcl(newAoi); service.saveAcl(newAoi); } @Test(expected = I...
CassandraAclRepository implements AclRepository { @Override public void deleteAcls(List<AclObjectIdentity> objectIdsToDelete) { assertAclObjectIdentityList(objectIdsToDelete); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN deleteAcls: objectIdsToDelete: " + objectIdsToDelete); } List<String> ids = new ArrayList<>(objectI...
@Test(expected = IllegalArgumentException.class) public void testDeleteNullAcl() { service.deleteAcls(null); } @Test public void testDeleteAclNotExisting() { AclObjectIdentity newAoi = new AclObjectIdentity(); newAoi.setId("invalid"); newAoi.setObjectClass(aoi_class); newAoi.setOwnerId(sid1); service.deleteAcls(Arrays....
BucketsHandler { public Bucket getCurrentBucket(String bucketsTableName, String objectId) { String query = "SELECT object_id, bucket_id, rows_count FROM " + bucketsTableName + " WHERE object_id = '" + objectId + "';"; ResultSet rs = session.execute(query); List<Row> rows = rs.all(); Row row = rows.isEmpty() ? null : ro...
@Test public void currentBucketShouldBeNull() { Bucket bucket = bucketsHandler.getCurrentBucket(BUCKETS_TABLE_NAME, "sampleObject"); Assert.assertNull(bucket); }
RemoverImpl implements Remover { @Override public void removeErrorReports(long taskId) { int retries = DEFAULT_RETRIES; while (true) { try { taskErrorDAO.removeErrors(taskId); break; } catch (Exception e) { if (retries-- > 0) { LOGGER.warn("Error while removing the error reports. Retries left: " + retries); waitForTheN...
@Test public void shouldSuccessfullyRemoveErrors() { doNothing().when(taskErrorDAO).removeErrors(eq(TASK_ID)); removerImpl.removeErrorReports(TASK_ID); verify(taskErrorDAO, times(1)).removeErrors((eq(TASK_ID))); } @Test(expected = Exception.class) public void shouldRetry5TimesBeforeFailingWhileRemovingErrorReports() { ...
BucketsHandler { public void increaseBucketCount(String bucketsTableName, Bucket bucket) { String query = "UPDATE " + bucketsTableName + " SET rows_count = rows_count + 1 WHERE object_id = '" + bucket.getObjectId() + "' AND bucket_id = " + UUID.fromString(bucket.getBucketId()) + ";"; session.execute(query); } BucketsHa...
@Test public void shouldCreateNewBucket() { Bucket bucket = new Bucket("sampleObjectId", new com.eaio.uuid.UUID().toString(), 0); bucketsHandler.increaseBucketCount(BUCKETS_TABLE_NAME, bucket); assertResults(bucket, 1); } @Test public void shouldUpdateCounterForExistingBucket() { Bucket bucket = new Bucket("sampleObjec...
StatisticsBolt extends AbstractDpsBolt { @Override public void execute(Tuple anchorTuple, StormTaskTuple stormTaskTuple) { try { if (!statsAlreadyCalculated(stormTaskTuple)) { LOGGER.info("Calculating file statistics for {}", stormTaskTuple); countStatistics(stormTaskTuple); markRecordStatsAsCalculated(stormTaskTuple);...
@Test public void testCountStatisticsSuccessfully() throws Exception { Tuple anchorTuple = mock(TupleImpl.class); byte[] fileData = Files.readAllBytes(Paths.get("src/test/resources/example1.xml")); StormTaskTuple tuple = new StormTaskTuple(TASK_ID, TASK_NAME, SOURCE_VERSION_URL, fileData, new HashMap<String, String>(),...
ValidationBolt extends AbstractDpsBolt { @Override public void execute(Tuple anchorTuple, StormTaskTuple stormTaskTuple) { try { reorderFileContent(stormTaskTuple); validateFileAndEmit(anchorTuple, stormTaskTuple); } catch (Exception e) { LOGGER.error("Validation Bolt error: {}", e.getMessage()); emitErrorNotification(...
@Test public void validateEdmInternalFile() throws Exception { Tuple anchorTuple = mock(TupleImpl.class); byte[] FILE_DATA = Files.readAllBytes(Paths.get("src/test/resources/Item_35834473_test.xml")); StormTaskTuple tuple = new StormTaskTuple(TASK_ID, TASK_NAME, SOURCE_VERSION_URL, FILE_DATA, prepareStormTaskTupleParam...
RecordStatisticsGenerator { public List<NodeStatistics> getStatistics() throws SAXException, IOException, ParserConfigurationException { Document doc = getParsedDocument(); doc.getDocumentElement().normalize(); Node root = doc.getDocumentElement(); addRootToNodeList(root); prepareNodeStatistics(root); return new ArrayL...
@Test public void nodeContentsSizeShouldBeSmallerThanMaximumSize() throws Exception { String fileContent = readFile("src/test/resources/BigContent.xml"); RecordStatisticsGenerator xmlParser = new RecordStatisticsGenerator(fileContent); List<NodeStatistics> nodeModelList = xmlParser.getStatistics(); for (NodeStatistics ...
EDMEnrichmentBolt extends ReadFileBolt { @Override public void execute(Tuple anchorTuple, StormTaskTuple stormTaskTuple) { if (stormTaskTuple.getParameter(PluginParameterKeys.RESOURCE_LINKS_COUNT) == null) { LOGGER.warn(NO_RESOURCES_DETAILED_MESSAGE); try (InputStream stream = getFileStreamByStormTuple(stormTaskTuple))...
@Test public void shouldEnrichTheFileSuccessfullyAndSendItToTheNextBolt() throws Exception { Tuple anchorTuple = mock(TupleImpl.class); try (InputStream stream = this.getClass().getResourceAsStream("/files/Item_35834473.xml")) { when(fileClient.getFile(eq(FILE_URL), eq(AUTHORIZATION), eq(AUTHORIZATION))).thenReturn(str...
ResourceProcessingBolt extends AbstractDpsBolt { @Override public void execute(Tuple anchorTuple, StormTaskTuple stormTaskTuple) { LOGGER.info("Starting resource processing"); long processingStartTime = new Date().getTime(); StringBuilder exception = new StringBuilder(); if (stormTaskTuple.getParameter(PluginParameterK...
@Test public void shouldSuccessfullyProcessTheResource() throws Exception { Tuple anchorTuple = mock(TupleImpl.class); stormTaskTuple.addParameter(PluginParameterKeys.RESOURCE_LINKS_COUNT, Integer.toString(5)); stormTaskTuple.addParameter(PluginParameterKeys.RESOURCE_LINK_KEY, "{\"resourceUrl\":\"http: String resourceN...
RemoverImpl implements Remover { @Override public void removeStatistics(long taskId) { int retries = DEFAULT_RETRIES; while (true) { try { cassandraNodeStatisticsDAO.removeStatistics(taskId); break; } catch (Exception e) { if (retries-- > 0) { LOGGER.warn("Error while removing the validation statistics. Retries left: "...
@Test public void shouldSuccessfullyRemoveStatistics() { doNothing().when(cassandraNodeStatisticsDAO).removeStatistics(eq(TASK_ID)); removerImpl.removeStatistics(TASK_ID); verify(cassandraNodeStatisticsDAO, times(1)).removeStatistics((eq(TASK_ID))); } @Test(expected = Exception.class) public void shouldRetry5TimesBefor...
HttpKafkaSpout extends CustomKafkaSpout { @Override public void deactivate() { LOGGER.info("Deactivate method was executed"); deactivateWaitingTasks(); deactivateCurrentTask(); LOGGER.info("Deactivate method was finished"); } HttpKafkaSpout(KafkaSpoutConfig spoutConf); HttpKafkaSpout(KafkaSpoutConfig spoutConf, String...
@Test public void deactivateShouldClearTheTaskQueue() throws Exception { final int taskCount = 10; for (int i = 0; i < taskCount; i++) { httpKafkaSpout.taskDownloader.taskQueue.put(new DpsTask()); } assertTrue(!httpKafkaSpout.taskDownloader.taskQueue.isEmpty()); httpKafkaSpout.deactivate(); assertTrue(httpKafkaSpout.ta...
ZipUnpackingService implements FileUnpackingService { public void unpackFile(final String compressedFilePath, final String destinationFolder) throws CompressionExtensionNotRecognizedException, IOException { final List<String> zipFiles = new ArrayList<>(); ZipUtil.unpack(new File(compressedFilePath), new File(destinatio...
@Test public void shouldUnpackTheZipFilesRecursively() throws CompressionExtensionNotRecognizedException, IOException { zipUnpackingService.unpackFile(DESTINATION_DIR + FILE_NAME + ZIP_EXTENSION, DESTINATION_DIR); Collection files = getXMLFiles(DESTINATION_DIR + DEFAULT_DESTINATION_NAME); assertNotNull(files); assertEq...