diff --git a/package-lock.json b/package-lock.json
index 895aa2e99f..837f6062a8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "Metadatamanagement",
- "version": "1.0.111-HOTFIX",
+ "version": "1.0.112",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 56870ea547..5975a7f899 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "Metadatamanagement",
- "version": "1.0.111-HOTFIX",
+ "version": "1.0.112",
"description": "Data Search for Higher Education Research and Science Studies",
"private": true,
"dependencies": {
diff --git a/pom.xml b/pom.xml
index 7891968f91..39ddcacb2b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
eu.dzhw.fdz
metadatamanagement
- 1.0.111-HOTFIX
+ 1.0.112
war
metadatamanagement
@@ -143,7 +143,7 @@
org.apache.commons
commons-compress
- 1.20
+ 1.21
org.apache.commons
diff --git a/reports/cpd-report.txt b/reports/cpd-report.txt
new file mode 100644
index 0000000000..69a5b466b9
--- /dev/null
+++ b/reports/cpd-report.txt
@@ -0,0 +1,20158 @@
+Found a 41 line (273 tokens) duplication in the following files:
+Starting at line 177 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 298 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+
+ public void testSimpleProjectForPostValidationWithWrongInformationForQuestion() throws IOException, Exception {
+
+ //Arrange
+ //Project
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ project.getConfiguration().setDataPackagesState(new ProjectState(true, true));
+ this.rdcProjectRepository.save(project);
+
+ //DataPackage (each project must have one)
+ DataPackage dataPackage = UnitTestCreateDomainObjectUtils.buildDataPackage(project.getId());
+ this.dataPackageRepository.save(dataPackage);
+
+ //Survey
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+ this.surveyRepository.save(survey);
+ List surveyNumbers = new ArrayList<>();
+ surveyNumbers.add(1);
+ List listOfSurveyIds = new ArrayList<>();
+ listOfSurveyIds.add(survey.getId());
+
+ //Variables
+ Variable variable1 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name1", 1, surveyNumbers);
+ this.variableRepository.save(variable1);
+ Variable variable2 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name2", 2, surveyNumbers);
+ this.variableRepository.save(variable2);
+ Variable variable3 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name3", 3, surveyNumbers);
+ this.variableRepository.save(variable3);
+
+ //DataSet
+ DataSet dataSet = UnitTestCreateDomainObjectUtils.buildDataSet(project.getId(), survey.getId(), 1);
+ this.dataSetRepository.save(dataSet);
+
+ //Instrument
+ Instrument instrument = UnitTestCreateDomainObjectUtils.buildInstrument(project.getId());
+ this.instrumentRepository.save(instrument);
+
+ //Question
+ Question question = UnitTestCreateDomainObjectUtils.buildQuestion(project.getId(), 123, "testProject-WrongQuestionname1"
+=====================================================================
+Found a 16 line (256 tokens) duplication in the following files:
+Starting at line 44 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/QDataPackage.java
+Starting at line 37 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSubDocument.java
+
+ public final StringPath id = createString("id");
+
+ public final ListPath institutions = this.createList("institutions", eu.dzhw.fdz.metadatamanagement.common.domain.I18nString.class, eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath lastModifiedBy = _super.lastModifiedBy;
+
+ //inherited
+ public final DateTimePath lastModifiedDate = _super.lastModifiedDate;
+
+ public final StringPath masterId = createString("masterId");
+
+ public final ListPath projectContributors = this.createList("projectContributors", eu.dzhw.fdz.metadatamanagement.common.domain.Person.class, eu.dzhw.fdz.metadatamanagement.common.domain.QPerson.class, PathInits.DIRECT2);
+
+ //inherited
+ public final BooleanPath shadow = _super.shadow;
+=====================================================================
+Found a 33 line (229 tokens) duplication in the following files:
+Starting at line 177 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 236 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 298 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+
+ public void testSimpleProjectForPostValidationWithWrongInformationForQuestion() throws IOException, Exception {
+
+ //Arrange
+ //Project
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ project.getConfiguration().setDataPackagesState(new ProjectState(true, true));
+ this.rdcProjectRepository.save(project);
+
+ //DataPackage (each project must have one)
+ DataPackage dataPackage = UnitTestCreateDomainObjectUtils.buildDataPackage(project.getId());
+ this.dataPackageRepository.save(dataPackage);
+
+ //Survey
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+ this.surveyRepository.save(survey);
+ List surveyNumbers = new ArrayList<>();
+ surveyNumbers.add(1);
+ List listOfSurveyIds = new ArrayList<>();
+ listOfSurveyIds.add(survey.getId());
+
+ //Variables
+ Variable variable1 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name1", 1, surveyNumbers);
+ this.variableRepository.save(variable1);
+ Variable variable2 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name2", 2, surveyNumbers);
+ this.variableRepository.save(variable2);
+ Variable variable3 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name3", 3, surveyNumbers);
+ this.variableRepository.save(variable3);
+
+ //DataSet
+ DataSet dataSet = UnitTestCreateDomainObjectUtils.buildDataSet(project.getId(), survey.getId(), 1);
+=====================================================================
+Found a 11 line (208 tokens) duplication in the following files:
+Starting at line 145 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 154 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public QInstrumentSearchDocument(Class extends InstrumentSearchDocument> type, PathMetadata metadata, PathInits inits) {
+ super(type, metadata, inits);
+ this.completeTitle = inits.isInitialized("completeTitle") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("completeTitle")) : null;
+ this.configuration = inits.isInitialized("configuration") ? new eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration(forProperty("configuration")) : null;
+ this.dataPackage = inits.isInitialized("dataPackage") ? new QDataPackageSubDocument(forProperty("dataPackage"), inits.get("dataPackage")) : null;
+ this.guiLabels = inits.isInitialized("guiLabels") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("guiLabels")) : null;
+ this.nestedDataPackage = inits.isInitialized("nestedDataPackage") ? new QDataPackageNestedDocument(forProperty("nestedDataPackage"), inits.get("nestedDataPackage")) : null;
+ this.release = inits.isInitialized("release") ? new eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QRelease(forProperty("release")) : null;
+ }
+
+}
+=====================================================================
+Found a 34 line (206 tokens) duplication in the following files:
+Starting at line 25 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 29 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSearchDocument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.instrumentmanagement.domain.QInstrument _super = new eu.dzhw.fdz.metadatamanagement.instrumentmanagement.domain.QInstrument(this);
+
+ // custom
+ // inherited
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.annotations);
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString completeTitle;
+
+ //inherited
+ public final ListPath conceptIds = _super.conceptIds;
+
+ public final ListPath concepts = this.createList("concepts", ConceptSubDocument.class, QConceptSubDocument.class, PathInits.DIRECT2);
+
+ public final eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration configuration;
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ //inherited
+ public final StringPath dataAcquisitionProjectId = _super.dataAcquisitionProjectId;
+
+ public final QDataPackageSubDocument dataPackage;
+
+ //inherited
+ public final StringPath dataPackageId = _super.dataPackageId;
+
+ public final ListPath dataSets = this.createList("dataSets", DataSetSubDocument.class, QDataSetSubDocument.class, PathInits.DIRECT2);
+
+ // custom
+ // inherited
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.description);
+=====================================================================
+Found a 58 line (156 tokens) duplication in the following files:
+Starting at line 150 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageOverviewService.java
+Starting at line 245 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetReportService.java
+
+ missingTexFiles.add(KEY_MAIN);
+ }
+
+ return missingTexFiles;
+ }
+
+ /**
+ * This method fills the tex templates.
+ *
+ * @param templateContent The content of a tex template.
+ * @param templateConfiguration The configuration for freemarker.
+ * @param fileName filename of the script which will be filled in this method.
+ * @return The filled tex templates as byte array.
+ * @throws IOException Handles IO Exception.
+ * @throws TemplateException Handles template Exceptions.
+ */
+ private String fillTemplate(String templateContent, Configuration templateConfiguration,
+ Map dataForTemplate, String fileName) throws IOException, TemplateException {
+ String templateName = "texTemplate";
+ if (fileName != null && fileName.trim().length() > 0) {
+ templateName = fileName;
+ }
+
+ // Read Template and escape elements
+ Template texTemplate = new Template(templateName,
+ ESCAPE_PREFIX + templateContent + ESCAPE_SUFFIX, templateConfiguration);
+
+ try (Writer stringWriter = new StringWriter()) {
+ texTemplate.process(dataForTemplate, stringWriter);
+
+ stringWriter.flush();
+ return stringWriter.toString();
+ }
+ }
+
+ /**
+ * This method save a latex file into GridFS/MongoDB based on a byteArrayOutputStream.
+ *
+ * @param fileName The name of the file to be saved
+ * @return return the file name of the saved latex template in the GridFS / MongoDB.
+ * @throws IOException thrown if a stream cannot be closed
+ */
+ @SuppressFBWarnings("OBL_UNSATISFIED_OBLIGATION")
+ private String saveCompleteZipFile(File zipFile, String fileName) throws IOException {
+ // No Update by API, so we have to delete first.
+ fileService.deleteTempFile(fileName);
+ // Save tex file
+ return fileService.saveTempFile(new FileInputStream(zipFile), fileName, CONTENT_TYPE_ZIP);
+ }
+
+ /**
+ * This method load all needed objects from the db for filling the tex template.
+ *
+ * @param dataPackageId the id of the data package.
+ * @return A HashMap with all data for the template filling. The Key is the name of the Object,
+ * which is used in the template.
+ */
+ private Map loadDataForTemplateFilling(String dataPackageId) {
+=====================================================================
+Found a 36 line (153 tokens) duplication in the following files:
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataSetNestedDocument.java
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentNestedDocument.java
+
+ public static final QDataSetNestedDocument dataSetNestedDocument = new QDataSetNestedDocument("dataSetNestedDocument");
+
+ public final QAbstractNestedSubDocument _super;
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString completeTitle;
+
+ //inherited
+ public final StringPath createdBy;
+
+ //inherited
+ public final DateTimePath createdDate;
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description;
+
+ public final StringPath id = createString("id");
+
+ //inherited
+ public final StringPath lastModifiedBy;
+
+ //inherited
+ public final DateTimePath lastModifiedDate;
+
+ public final StringPath masterId = createString("masterId");
+
+ public final BooleanPath shadow = createBoolean("shadow");
+
+ public final StringPath successorId = createString("successorId");
+
+ public final ListPath surveyIds = this.createList("surveyIds", String.class, StringPath.class, PathInits.DIRECT2);
+
+ //inherited
+ public final NumberPath version;
+
+ public QDataSetNestedDocument(String variable) {
+=====================================================================
+Found a 7 line (147 tokens) duplication in the following files:
+Starting at line 145 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 164 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSearchDocument.java
+Starting at line 154 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public QInstrumentSearchDocument(Class extends InstrumentSearchDocument> type, PathMetadata metadata, PathInits inits) {
+ super(type, metadata, inits);
+ this.completeTitle = inits.isInitialized("completeTitle") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("completeTitle")) : null;
+ this.configuration = inits.isInitialized("configuration") ? new eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration(forProperty("configuration")) : null;
+ this.dataPackage = inits.isInitialized("dataPackage") ? new QDataPackageSubDocument(forProperty("dataPackage"), inits.get("dataPackage")) : null;
+ this.guiLabels = inits.isInitialized("guiLabels") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("guiLabels")) : null;
+ this.nestedDataPackage = inits.isInitialized("nestedDataPackage") ? new QDataPackageNestedDocument(forProperty("nestedDataPackage"), inits.get("nestedDataPackage")) : null;
+=====================================================================
+Found a 23 line (146 tokens) duplication in the following files:
+Starting at line 29 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+Starting at line 32 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableSearchDocument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.annotations);
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString completeTitle;
+
+ public final ListPath concepts = this.createList("concepts", ConceptSubDocument.class, QConceptSubDocument.class, PathInits.DIRECT2);
+
+ public final eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration configuration;
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ //inherited
+ public final StringPath dataAcquisitionProjectId = _super.dataAcquisitionProjectId;
+
+ public final QDataPackageSubDocument dataPackage;
+
+ //inherited
+ public final StringPath dataPackageId = _super.dataPackageId;
+
+ public final ListPath dataSets = this.createList("dataSets", DataSetSubDocument.class, QDataSetSubDocument.class, PathInits.DIRECT2);
+=====================================================================
+Found a 23 line (145 tokens) duplication in the following files:
+Starting at line 119 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+
+ public void testDeleteSingleAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ DataSetAttachmentMetadata dataSetAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildDataSetAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("dataSetAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(dataSetAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/data-sets/attachments").file(attachment)
+ .file(metadata)).andExpect(status().isCreated());
+
+ dataSetAttachmentMetadata.generateId();
+
+ // ensure that there is one attachment
+ mockMvc
+ .perform(get("/api/data-sets/" + dataSetAttachmentMetadata.getDataSetId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));;
+
+ // delete the file
+ mockMvc
+ .perform(delete("/api/data-sets/" + dataSetAttachmentMetadata.getDataSetId()
+ + "/attachments/" + attachment.getOriginalFilename()))
+=====================================================================
+Found a 22 line (143 tokens) duplication in the following files:
+Starting at line 109 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 141 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+
+ public void testDeleteSingleAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ ConceptAttachmentMetadata conceptAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildConceptAttachmentMetadata("con-conceptid$");
+ MockMultipartFile metadata = new MockMultipartFile("conceptAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(conceptAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/concepts/attachments").file(attachment)
+ .file(metadata)).andExpect(status().isCreated());
+
+ conceptAttachmentMetadata.generateId();
+
+ // ensure that there is one file
+ mockMvc
+ .perform(get("/api/concepts/" + conceptAttachmentMetadata.getConceptId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));
+
+ // delete the file
+ mockMvc
+ .perform(delete("/api/concepts/" + conceptAttachmentMetadata.getConceptId()
+ + "/attachments/" + attachment.getOriginalFilename()))
+=====================================================================
+Found a 23 line (143 tokens) duplication in the following files:
+Starting at line 119 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+
+ public void testDeleteAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ DataPackageAttachmentMetadata dataPackageAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildDataPackageAttachmentMetadata("projectid");
+ MockMultipartFile metadata = new MockMultipartFile("dataPackageAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(dataPackageAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/data-packages/attachments")
+ .file(attachment).file(metadata)).andExpect(status().isCreated());
+
+ dataPackageAttachmentMetadata.generateId();
+
+ // ensure that there is one attachment
+ mockMvc
+ .perform(get("/api/data-packages/" + dataPackageAttachmentMetadata.getDataPackageId()
+ + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));
+
+ // delete the file
+ mockMvc
+ .perform(delete("/api/data-packages/" + dataPackageAttachmentMetadata.getDataPackageId()
+ + "/attachments/" + attachment.getOriginalFilename()))
+=====================================================================
+Found a 17 line (143 tokens) duplication in the following files:
+Starting at line 244 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+Starting at line 270 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+
+ variable.setScaleLevel(ScaleLevels.ORDINAL);
+ List validResponses = new ArrayList<>();
+ variable.getDistribution().setValidResponses(validResponses);
+ variable.getDistribution().getStatistics().setMaximum("2017-01-31");
+ variable.getDistribution().getStatistics().setMinimum("2017-01-30");
+ variable.getDistribution().getStatistics().setMedian("2017-01-30");
+ variable.getDistribution().getStatistics().setThirdQuartile("2017-01-31");
+ variable.getDistribution().getStatistics().setFirstQuartile("2017-01-30");
+
+ // create the variable with a survey but without a project
+ mockMvc.perform(put(API_VARIABLES_URI + "/" + variable.getId())
+ .content(TestUtil.convertObjectToJsonBytes(variable))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+ }
+
+ @Test
+ public void testCreateDateVariableWithNominalScaleLevel() throws Exception {
+=====================================================================
+Found a 7 line (143 tokens) duplication in the following files:
+Starting at line 21 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/domain/QConcept.java
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSubDocument.java
+
+ public static final QConcept concept = new QConcept("concept");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractRdcDomainObject _super = new eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractRdcDomainObject(this);
+
+ public final ListPath authors = this.createList("authors", eu.dzhw.fdz.metadatamanagement.common.domain.Person.class, eu.dzhw.fdz.metadatamanagement.common.domain.QPerson.class, PathInits.DIRECT2);
+
+ public final StringPath citationHint = createString("citationHint");
+=====================================================================
+Found a 18 line (140 tokens) duplication in the following files:
+Starting at line 170 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackagePublicListResourceControllerTest.java
+Starting at line 196 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackagePublicListResourceControllerTest.java
+
+ DataPackage dataPackage = UnitTestCreateDomainObjectUtils.buildDataPackage(project.getId());
+
+ // create the dataPackage with the given id
+ mockMvc.perform(put(API_DATAPACKAGE_URI + "/" + dataPackage.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataPackage))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+
+ // release the project
+ project.setRelease(UnitTestCreateDomainObjectUtils.buildRelease());
+ project.getRelease().setPinToStartPage(true);
+ mockMvc.perform(put("/api/data-acquisition-projects" + "/" + project.getId())
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(TestUtil.convertObjectToJsonBytes(project))).andExpect(status().isNoContent());
+ shadowCopyQueueItemService.executeShadowCopyActions();
+
+ UnitTestUserManagementUtils.logout();
+ // ensure that there is one pinned data package
+ mockMvc.perform(get(API_DATAPACKAGE_URI + "?pinned=true")).andExpect(status().isOk())
+=====================================================================
+Found a 21 line (140 tokens) duplication in the following files:
+Starting at line 101 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 177 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+
+ public void testDeleteSingleAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ InstrumentAttachmentMetadata instrumentAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildInstrumentAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("instrumentAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(instrumentAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/instruments/attachments")
+ .file(attachment).file(metadata)).andExpect(status().isCreated());
+
+ // ensure the uploaded file exists
+ mockMvc
+ .perform(get(
+ "/api/instruments/" + instrumentAttachmentMetadata.getInstrumentId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));
+
+ // delete the file
+ mockMvc
+ .perform(delete("/api/instruments/" + instrumentAttachmentMetadata.getInstrumentId()
+ + "/attachments/" + attachment.getOriginalFilename()))
+=====================================================================
+Found a 18 line (140 tokens) duplication in the following files:
+Starting at line 116 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 143 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+
+ public void testDeleteSingleAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ SurveyAttachmentMetadata surveyAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildSurveyAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("surveyAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(surveyAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/surveys/attachments").file(attachment)
+ .file(metadata)).andExpect(status().isCreated());
+
+ // ensure that there is one attachment
+ mockMvc.perform(get("/api/surveys/" + surveyAttachmentMetadata.getSurveyId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));;
+
+ // delete the file
+ mockMvc.perform(delete("/api/surveys/" + surveyAttachmentMetadata.getSurveyId()
+ + "/attachments/" + attachment.getOriginalFilename()))
+=====================================================================
+Found a 22 line (140 tokens) duplication in the following files:
+Starting at line 126 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResponseRateImageResourceTest.java
+Starting at line 156 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResponseRateImageResourceTest.java
+
+ public void testDeleteAllResponseRateImages() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("image", FILE_NAME, "image/png", "fakeimage".getBytes());
+ SurveyResponseRateImageMetadata surveyResponseRateImageMetadata =
+ createResponseRateImageMetadata();
+ MockMultipartFile metadata = new MockMultipartFile("surveyResponseRateImageMetadata", FILE_NAME,
+ "application/json", TestUtil.convertObjectToJsonBytes(surveyResponseRateImageMetadata));
+
+ // create the image
+ MvcResult result = mockMvc
+ .perform(
+ MockMvcRequestBuilders.multipart("/api/surveys/images").file(attachment).file(metadata))
+ .andExpect(status().isCreated()).andReturn();
+
+ // assert that the file exists
+ String fileUri = result.getResponse().getHeaderValue(HttpHeaders.LOCATION).toString();
+ mockMvc.perform(get(fileUri)).andExpect(status().isOk());
+
+ // delete all images
+ mockMvc
+ .perform(
+ delete("/api/surveys/" + surveyResponseRateImageMetadata.getSurveyId() + "/images"))
+=====================================================================
+Found a 19 line (140 tokens) duplication in the following files:
+Starting at line 21 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/domain/QTags.java
+Starting at line 21 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/QTags.java
+
+ public static final QTags tags = new QTags("tags");
+
+ public final SetPath de = this.createSet("de", String.class, StringPath.class, PathInits.DIRECT2);
+
+ public final SetPath en = this.createSet("en", String.class, StringPath.class, PathInits.DIRECT2);
+
+ public QTags(String variable) {
+ super(Tags.class, forVariable(variable));
+ }
+
+ public QTags(Path extends Tags> path) {
+ super(path.getType(), path.getMetadata());
+ }
+
+ public QTags(PathMetadata metadata) {
+ super(Tags.class, metadata);
+ }
+
+}
+=====================================================================
+Found a 23 line (140 tokens) duplication in the following files:
+Starting at line 36 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 40 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSearchDocument.java
+Starting at line 33 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public final ListPath concepts = this.createList("concepts", ConceptSubDocument.class, QConceptSubDocument.class, PathInits.DIRECT2);
+
+ public final eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration configuration;
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ //inherited
+ public final StringPath dataAcquisitionProjectId = _super.dataAcquisitionProjectId;
+
+ public final QDataPackageSubDocument dataPackage;
+
+ //inherited
+ public final StringPath dataPackageId = _super.dataPackageId;
+
+ public final ListPath dataSets = this.createList("dataSets", DataSetSubDocument.class, QDataSetSubDocument.class, PathInits.DIRECT2);
+
+ // custom
+ // inherited
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.description);
+=====================================================================
+Found a 23 line (135 tokens) duplication in the following files:
+Starting at line 27 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+Starting at line 25 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public final ListPath accessWays = this.createList("accessWays", String.class, StringPath.class, PathInits.DIRECT2);
+
+ // custom
+ // inherited
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.annotations);
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString completeTitle;
+
+ public final ListPath concepts = this.createList("concepts", ConceptSubDocument.class, QConceptSubDocument.class, PathInits.DIRECT2);
+
+ public final eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration configuration;
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ //inherited
+ public final StringPath dataAcquisitionProjectId = _super.dataAcquisitionProjectId;
+
+ //inherited
+ public final ListPath dataCurators = _super.dataCurators;
+=====================================================================
+Found a 13 line (134 tokens) duplication in the following files:
+Starting at line 244 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+Starting at line 270 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+Starting at line 298 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+
+ variable.setScaleLevel(ScaleLevels.ORDINAL);
+ List validResponses = new ArrayList<>();
+ variable.getDistribution().setValidResponses(validResponses);
+ variable.getDistribution().getStatistics().setMaximum("2017-01-31");
+ variable.getDistribution().getStatistics().setMinimum("2017-01-30");
+ variable.getDistribution().getStatistics().setMedian("2017-01-30");
+ variable.getDistribution().getStatistics().setThirdQuartile("2017-01-31");
+ variable.getDistribution().getStatistics().setFirstQuartile("2017-01-30");
+
+ // create the variable with a survey but without a project
+ mockMvc.perform(put(API_VARIABLES_URI + "/" + variable.getId())
+ .content(TestUtil.convertObjectToJsonBytes(variable))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+=====================================================================
+Found a 13 line (134 tokens) duplication in the following files:
+Starting at line 64 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptNestedDocument.java
+Starting at line 70 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageNestedDocument.java
+
+ public QConceptNestedDocument(Class extends ConceptNestedDocument> type, PathMetadata metadata, PathInits inits) {
+ super(type, metadata, inits);
+ this._super = new QAbstractNestedSubDocument(type, metadata, inits);
+ this.completeTitle = inits.isInitialized("completeTitle") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("completeTitle")) : null;
+ this.createdBy = _super.createdBy;
+ this.createdDate = _super.createdDate;
+ this.lastModifiedBy = _super.lastModifiedBy;
+ this.lastModifiedDate = _super.lastModifiedDate;
+ this.title = inits.isInitialized("title") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("title")) : null;
+ this.version = _super.version;
+ }
+
+}
+=====================================================================
+Found a 10 line (134 tokens) duplication in the following files:
+Starting at line 72 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 88 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataSetSearchDocument.java
+
+ public final ListPath nestedInstruments = this.createList("nestedInstruments", InstrumentNestedDocument.class, QInstrumentNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedSurveys = this.createList("nestedSurveys", SurveyNestedDocument.class, QSurveyNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedVariables = this.createList("nestedVariables", VariableNestedDocument.class, QVariableNestedDocument.class, PathInits.DIRECT2);
+
+ //inherited
+ public final SetPath originalLanguages = _super.originalLanguages;
+=====================================================================
+Found a 19 line (134 tokens) duplication in the following files:
+Starting at line 31 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+Starting at line 32 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableSearchDocument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.annotations);
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString completeTitle;
+
+ public final ListPath concepts = this.createList("concepts", ConceptSubDocument.class, QConceptSubDocument.class, PathInits.DIRECT2);
+
+ public final eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration configuration;
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ //inherited
+ public final StringPath dataAcquisitionProjectId = _super.dataAcquisitionProjectId;
+
+ //inherited
+ public final ListPath dataCurators = _super.dataCurators;
+=====================================================================
+Found a 13 line (134 tokens) duplication in the following files:
+Starting at line 74 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataSetNestedDocument.java
+Starting at line 74 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentNestedDocument.java
+
+ public QDataSetNestedDocument(Class extends DataSetNestedDocument> type, PathMetadata metadata, PathInits inits) {
+ super(type, metadata, inits);
+ this._super = new QAbstractNestedSubDocument(type, metadata, inits);
+ this.completeTitle = inits.isInitialized("completeTitle") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("completeTitle")) : null;
+ this.createdBy = _super.createdBy;
+ this.createdDate = _super.createdDate;
+ this.description = inits.isInitialized("description") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("description")) : null;
+ this.lastModifiedBy = _super.lastModifiedBy;
+ this.lastModifiedDate = _super.lastModifiedDate;
+ this.version = _super.version;
+ }
+
+}
+=====================================================================
+Found a 16 line (132 tokens) duplication in the following files:
+Starting at line 94 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+Starting at line 128 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+
+ mockMvc.perform(put(API_INSTRUMENTS_URI + "/" + instrument.getId())
+ .content(TestUtil.convertObjectToJsonBytes(instrument)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ elasticsearchUpdateQueueService.processAllQueueItems();
+
+ // check that there is one instrument document
+ assertThat(elasticsearchAdminService.countAllDocuments(), equalTo(1L));
+
+ // check that auditing attributes have been set
+ mockMvc.perform(get(API_INSTRUMENTS_URI + "/" + instrument.getId()))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.createdDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.lastModifiedDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.createdBy", is("test")))
+ .andExpect(jsonPath("$.lastModifiedBy", is("test")));
+=====================================================================
+Found a 16 line (132 tokens) duplication in the following files:
+Starting at line 98 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 130 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+
+ mockMvc.perform(put(API_QUESTIONS_URI + "/" + question.getId())
+ .content(TestUtil.convertObjectToJsonBytes(question)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ elasticsearchUpdateQueueService.processAllQueueItems();
+
+ // check that there is one question documents
+ assertThat(elasticsearchAdminService.countAllDocuments(), equalTo(1L));
+
+ // check that auditing attributes have been set
+ mockMvc.perform(get(API_QUESTIONS_URI + "/" + question.getId()))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.createdDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.lastModifiedDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.createdBy", is("user")))
+ .andExpect(jsonPath("$.lastModifiedBy", is("user")));
+=====================================================================
+Found a 15 line (132 tokens) duplication in the following files:
+Starting at line 114 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+Starting at line 146 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+
+ mockMvc.perform(put(API_VARIABLES_URI + "/" + variable.getId())
+ .content(TestUtil.convertObjectToJsonBytes(variable))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+
+ queueService.processAllQueueItems();
+
+ // check that there is one variable search document
+ assertThat(elasticsearchAdminService.countAllDocuments(), equalTo(1L));
+
+ // check that auditing attributes have been set
+ mockMvc.perform(get(API_VARIABLES_URI + "/" + variable.getId())).andExpect(status().isOk())
+ .andExpect(jsonPath("$.createdDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.lastModifiedDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.createdBy", is("user")))
+ .andExpect(jsonPath("$.lastModifiedBy", is("user")));
+=====================================================================
+Found a 18 line (131 tokens) duplication in the following files:
+Starting at line 119 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 185 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+
+ public void testDeleteSingleAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ DataSetAttachmentMetadata dataSetAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildDataSetAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("dataSetAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(dataSetAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/data-sets/attachments").file(attachment)
+ .file(metadata)).andExpect(status().isCreated());
+
+ dataSetAttachmentMetadata.generateId();
+
+ // ensure that there is one attachment
+ mockMvc
+ .perform(get("/api/data-sets/" + dataSetAttachmentMetadata.getDataSetId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));;
+=====================================================================
+Found a 17 line (129 tokens) duplication in the following files:
+Starting at line 109 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 141 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 173 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+
+ public void testDeleteSingleAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ ConceptAttachmentMetadata conceptAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildConceptAttachmentMetadata("con-conceptid$");
+ MockMultipartFile metadata = new MockMultipartFile("conceptAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(conceptAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/concepts/attachments").file(attachment)
+ .file(metadata)).andExpect(status().isCreated());
+
+ conceptAttachmentMetadata.generateId();
+
+ // ensure that there is one file
+ mockMvc
+ .perform(get("/api/concepts/" + conceptAttachmentMetadata.getConceptId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));
+=====================================================================
+Found a 18 line (129 tokens) duplication in the following files:
+Starting at line 119 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 185 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+
+ public void testDeleteAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ DataPackageAttachmentMetadata dataPackageAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildDataPackageAttachmentMetadata("projectid");
+ MockMultipartFile metadata = new MockMultipartFile("dataPackageAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(dataPackageAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/data-packages/attachments")
+ .file(attachment).file(metadata)).andExpect(status().isCreated());
+
+ dataPackageAttachmentMetadata.generateId();
+
+ // ensure that there is one attachment
+ mockMvc
+ .perform(get("/api/data-packages/" + dataPackageAttachmentMetadata.getDataPackageId()
+ + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));
+=====================================================================
+Found a 19 line (128 tokens) duplication in the following files:
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/QDataSet.java
+Starting at line 20 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/QSurvey.java
+
+ public static final QDataSet dataSet = new QDataSet("dataSet");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject _super = new eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject(this);
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("annotations"));
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("description"));
+=====================================================================
+Found a 16 line (126 tokens) duplication in the following files:
+Starting at line 101 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 133 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 177 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+
+ public void testDeleteSingleAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ InstrumentAttachmentMetadata instrumentAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildInstrumentAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("instrumentAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(instrumentAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/instruments/attachments")
+ .file(attachment).file(metadata)).andExpect(status().isCreated());
+
+ // ensure the uploaded file exists
+ mockMvc
+ .perform(get(
+ "/api/instruments/" + instrumentAttachmentMetadata.getInstrumentId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));
+=====================================================================
+Found a 14 line (126 tokens) duplication in the following files:
+Starting at line 116 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 143 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 170 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+
+ public void testDeleteSingleAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ SurveyAttachmentMetadata surveyAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildSurveyAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("surveyAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(surveyAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/surveys/attachments").file(attachment)
+ .file(metadata)).andExpect(status().isCreated());
+
+ // ensure that there is one attachment
+ mockMvc.perform(get("/api/surveys/" + surveyAttachmentMetadata.getSurveyId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));;
+=====================================================================
+Found a 17 line (126 tokens) duplication in the following files:
+Starting at line 87 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResponseRateImageResourceTest.java
+Starting at line 126 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResponseRateImageResourceTest.java
+Starting at line 156 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResponseRateImageResourceTest.java
+
+ public void testCreateSurveyResponseRateImageMetadata() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("image", FILE_NAME, "image/png", "fakeimage".getBytes());
+ SurveyResponseRateImageMetadata surveyResponseRateImageMetadata =
+ createResponseRateImageMetadata();
+ MockMultipartFile metadata = new MockMultipartFile("surveyResponseRateImageMetadata", FILE_NAME,
+ "application/json", TestUtil.convertObjectToJsonBytes(surveyResponseRateImageMetadata));
+
+ // create the image
+ MvcResult result = mockMvc
+ .perform(
+ MockMvcRequestBuilders.multipart("/api/surveys/images").file(attachment).file(metadata))
+ .andExpect(status().isCreated()).andReturn();
+
+ // assert that the file exists
+ String fileUri = result.getResponse().getHeaderValue(HttpHeaders.LOCATION).toString();
+ mockMvc.perform(get(fileUri)).andExpect(status().isOk());
+=====================================================================
+Found a 18 line (125 tokens) duplication in the following files:
+Starting at line 79 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageOverviewService.java
+Starting at line 131 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetReportService.java
+
+ log.debug("Start generating report for {} and dataPackageId {}", originalName, dataPackageId);
+ try {
+ // Configuration, based on Freemarker Version 2.3.23
+ Configuration templateConfiguration = new Configuration(Configuration.VERSION_2_3_23);
+ templateConfiguration.setDefaultEncoding(StandardCharsets.UTF_8.toString());
+ templateConfiguration.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
+ templateConfiguration.setNumberFormat("0.######");
+ log.debug("Prepare Zip enviroment config");
+ // Prepare Zip enviroment config
+ Map env = new HashMap<>();
+ env.put("create", "true");
+ env.put("encoding", StandardCharsets.UTF_8.name());
+ // Create tmp file
+ URI uriOfZipFile = URI.create("jar:" + zipTmpFilePath.toUri());
+ try (FileSystem zipFileSystem = FileSystems.newFileSystem(uriOfZipFile, env);) {
+ // Check missing files.
+ log.debug("Check missing files.");
+ List missingTexFiles = this.validateDataPackageOverviewStructure(zipFileSystem);
+=====================================================================
+Found a 21 line (123 tokens) duplication in the following files:
+Starting at line 90 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 119 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 185 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+
+ public void testUploadValidAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ DataSetAttachmentMetadata dataSetAttachmentMetadata = UnitTestCreateDomainObjectUtils
+ .buildDataSetAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("dataSetAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(dataSetAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/data-sets/attachments")
+ .file(attachment)
+ .file(metadata))
+ .andExpect(status().isCreated());
+
+ dataSetAttachmentMetadata.generateId();
+
+ // read the created attachment and check the version
+ mockMvc.perform(
+ get("/api/data-sets/" + dataSetAttachmentMetadata.getDataSetId() + "/attachments"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.[0].dataSetId", is(dataSetAttachmentMetadata.getDataSetId())))
+=====================================================================
+Found a 21 line (123 tokens) duplication in the following files:
+Starting at line 270 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 387 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+
+ surveyIds.add(project.getId() + "-WrongSurveyId");
+ dataSet.setSurveyIds(surveyIds);
+ this.dataSetRepository.save(dataSet);
+
+ //Instrument
+ Instrument instrument = UnitTestCreateDomainObjectUtils.buildInstrument(project.getId());
+ this.instrumentRepository.save(instrument);
+
+ //Atomic Question
+ Question question = UnitTestCreateDomainObjectUtils.buildQuestion(project.getId(), 123, instrument.getId()
+ );
+ this.questionRepository.save(question);
+ QuestionImageMetadata questionImageMetadata =
+ UnitTestCreateDomainObjectUtils.buildQuestionImageMetadata(project.getId(), question.getId());
+ UnitTestImageHelper.saveQuestionImage(this.questionImageService, questionImageMetadata);
+
+
+ // Act & Assert
+ mockMvc.perform(post(API_DATA_ACQUISITION_PROJECTS_POST_VALIDATION_URI))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.errors", hasSize(4)))
+=====================================================================
+Found a 21 line (121 tokens) duplication in the following files:
+Starting at line 79 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 109 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 141 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 173 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+
+ public void testUploadValidAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ ConceptAttachmentMetadata conceptAttachmentMetadata = UnitTestCreateDomainObjectUtils
+ .buildConceptAttachmentMetadata("con-conceptid$");
+ MockMultipartFile metadata = new MockMultipartFile("conceptAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(conceptAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/concepts/attachments")
+ .file(attachment)
+ .file(metadata))
+ .andExpect(status().isCreated());
+
+ conceptAttachmentMetadata.generateId();
+
+ // read the created attachment and check the version
+ mockMvc.perform(
+ get("/api/concepts/" + conceptAttachmentMetadata.getConceptId() + "/attachments"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.[0].conceptId", is(conceptAttachmentMetadata.getConceptId())))
+=====================================================================
+Found a 21 line (121 tokens) duplication in the following files:
+Starting at line 89 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 119 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 185 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+
+ public void testUploadValidAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ DataPackageAttachmentMetadata dataPackageAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildDataPackageAttachmentMetadata("projectid");
+ MockMultipartFile metadata = new MockMultipartFile("dataPackageAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(dataPackageAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/data-packages/attachments")
+ .file(attachment).file(metadata)).andExpect(status().isCreated());
+
+ dataPackageAttachmentMetadata.generateId();
+
+ // read the created attachment and check the version
+ mockMvc
+ .perform(get("/api/data-packages/"
+ + dataPackageAttachmentMetadata.getDataPackageId() + "/attachments"))
+ .andExpect(status().isOk())
+ .andExpect(
+ jsonPath("$.[0].dataPackageId", is(dataPackageAttachmentMetadata.getDataPackageId())))
+=====================================================================
+Found a 15 line (121 tokens) duplication in the following files:
+Starting at line 218 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageAttachmentShadowCopyServiceTest.java
+Starting at line 218 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentShadowCopyServiceTest.java
+Starting at line 222 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentShadowCopyServiceTest.java
+Starting at line 215 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/service/SurveyAttachmentShadowCopyServiceTest.java
+
+ String filename = DataPackageAttachmentFilenameBuilder.buildFileName(metadata);
+ gridFsMetadataUpdateService.store(is, filename, "text/plain", metadata);
+ is.close();
+ }
+
+ private void assertExpectedFilesExistence(List expectedFiles) {
+ Iterator it = gridFsOperations.find(new Query()).iterator();
+ List fileNames = new ArrayList<>();
+ while (it.hasNext()) {
+ fileNames.add(it.next().getFilename());
+ }
+ assertThat(fileNames.size(), equalTo(expectedFiles.size()));
+ assertThat(fileNames, containsInAnyOrder(expectedFiles.toArray()));
+ }
+}
+=====================================================================
+Found a 4 line (121 tokens) duplication in the following files:
+Starting at line 61 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/QDataPackage.java
+Starting at line 53 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSubDocument.java
+
+ public final ListPath sponsors = this.createList("sponsors", eu.dzhw.fdz.metadatamanagement.common.domain.I18nString.class, eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString.class, PathInits.DIRECT2);
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString studySeries = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("studySeries"));
+=====================================================================
+Found a 19 line (118 tokens) duplication in the following files:
+Starting at line 74 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 101 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 133 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 177 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+
+ public void testUploadValidAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ InstrumentAttachmentMetadata instrumentAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildInstrumentAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("instrumentAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(instrumentAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/instruments/attachments")
+ .file(attachment).file(metadata)).andExpect(status().isCreated());
+
+ // read the created attachment and check the version
+ mockMvc
+ .perform(get(
+ "/api/instruments/" + instrumentAttachmentMetadata.getInstrumentId() + "/attachments"))
+ .andExpect(status().isOk())
+ .andExpect(
+ jsonPath("$.[0].instrumentId", is(instrumentAttachmentMetadata.getInstrumentId())))
+=====================================================================
+Found a 18 line (118 tokens) duplication in the following files:
+Starting at line 89 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 116 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 143 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 170 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+
+ public void testUploadValidAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ SurveyAttachmentMetadata surveyAttachmentMetadata = UnitTestCreateDomainObjectUtils
+ .buildSurveyAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("surveyAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(surveyAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/surveys/attachments")
+ .file(attachment)
+ .file(metadata))
+ .andExpect(status().isCreated());
+
+ // read the created attachment and check the version
+ mockMvc.perform(
+ get("/api/surveys/" + surveyAttachmentMetadata.getSurveyId() + "/attachments"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.[0].surveyId", is(surveyAttachmentMetadata.getSurveyId())))
+=====================================================================
+Found a 19 line (117 tokens) duplication in the following files:
+Starting at line 146 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+Starting at line 186 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+
+ public void testUpdateInstrument() throws Exception {
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ this.dataAcquisitionProjectRepository.save(project);
+
+ Instrument instrument =
+ UnitTestCreateDomainObjectUtils.buildInstrument(project.getId(), project.getId() + "-sy1");
+
+ // Act and Assert
+ // create the instrument with the given id
+ mockMvc.perform(put(API_INSTRUMENTS_URI + "/" + instrument.getId())
+ .content(TestUtil.convertObjectToJsonBytes(instrument)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ // delete the survey
+ mockMvc.perform(delete(API_INSTRUMENTS_URI + "/" + instrument.getId()))
+ .andExpect(status().is2xxSuccessful());
+
+ instrument.setTitle(new I18nString("Hurz2", "Hurz2"));
+=====================================================================
+Found a 20 line (117 tokens) duplication in the following files:
+Starting at line 271 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 330 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 388 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+
+ dataSet.setSurveyIds(surveyIds);
+ this.dataSetRepository.save(dataSet);
+
+ //Instrument
+ Instrument instrument = UnitTestCreateDomainObjectUtils.buildInstrument(project.getId());
+ this.instrumentRepository.save(instrument);
+
+ //Atomic Question
+ Question question = UnitTestCreateDomainObjectUtils.buildQuestion(project.getId(), 123, instrument.getId()
+ );
+ this.questionRepository.save(question);
+ QuestionImageMetadata questionImageMetadata =
+ UnitTestCreateDomainObjectUtils.buildQuestionImageMetadata(project.getId(), question.getId());
+ UnitTestImageHelper.saveQuestionImage(this.questionImageService, questionImageMetadata);
+
+
+ // Act & Assert
+ mockMvc.perform(post(API_DATA_ACQUISITION_PROJECTS_POST_VALIDATION_URI))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.errors", hasSize(4)))
+=====================================================================
+Found a 17 line (115 tokens) duplication in the following files:
+Starting at line 188 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 74 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentVersionsResourceTest.java
+
+ .perform(get("/api/concepts/" + conceptAttachmentMetadata.getConceptId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));
+
+ // update the metadata
+ ConceptAttachmentMetadata current =
+ conceptAttachmentService.findAllByConcept(conceptAttachmentMetadata.getConceptId()).get(0);
+ current.setLanguage("en");
+
+ mockMvc
+ .perform(put("/api/concepts/" + conceptAttachmentMetadata.getConceptId() + "/attachments/"
+ + attachment.getOriginalFilename()).content(TestUtil.convertObjectToJsonBytes(current))
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isNoContent());
+
+ // read the updated attachment and check the version
+ mockMvc
+ .perform(get("/api/concepts/" + conceptAttachmentMetadata.getConceptId() + "/attachments"))
+=====================================================================
+Found a 18 line (115 tokens) duplication in the following files:
+Starting at line 200 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 74 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentVersionsResourceTest.java
+
+ .perform(get("/api/data-sets/" + dataSetAttachmentMetadata.getDataSetId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));;
+
+ // update the metadata
+ DataSetAttachmentMetadata current =
+ dataSetAttachmentService.findAllByDataSet(dataSetAttachmentMetadata.getDataSetId()).get(0);
+ current.setLanguage("en");
+
+ mockMvc
+ .perform(put("/api/data-sets/" + dataSetAttachmentMetadata.getDataSetId() + "/attachments/"
+ + attachment.getOriginalFilename()).content(TestUtil.convertObjectToJsonBytes(current))
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isNoContent());
+
+ // read the updated attachment and check the version
+ mockMvc
+ .perform(get(
+ "/api/data-sets/" + dataSetAttachmentMetadata.getDataSetId() + "/attachments"))
+=====================================================================
+Found a 17 line (115 tokens) duplication in the following files:
+Starting at line 182 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 73 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentVersionsResourceTest.java
+
+ mockMvc.perform(get("/api/surveys/" + surveyAttachmentMetadata.getSurveyId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(1)));;
+
+ // update the metadata
+ SurveyAttachmentMetadata current =
+ surveyAttachmentService.findAllBySurvey(surveyAttachmentMetadata.getSurveyId()).get(0);
+ current.setLanguage("en");
+
+ mockMvc
+ .perform(put("/api/surveys/" + surveyAttachmentMetadata.getSurveyId() + "/attachments/"
+ + attachment.getOriginalFilename()).content(TestUtil.convertObjectToJsonBytes(current))
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isNoContent());
+
+ // read the updated attachment and check the version
+ mockMvc
+ .perform(get("/api/surveys/" + surveyAttachmentMetadata.getSurveyId() + "/attachments"))
+=====================================================================
+Found a 11 line (114 tokens) duplication in the following files:
+Starting at line 105 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+Starting at line 140 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+
+ mockMvc.perform(put(API_DATASETS_URI + "/" + dataSet.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataSet)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ // check that auditing attributes have been set
+ mockMvc.perform(get(API_DATASETS_URI + "/" + dataSet.getId()))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.createdDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.lastModifiedDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.createdBy", is("user")))
+ .andExpect(jsonPath("$.lastModifiedBy", is("user")));
+=====================================================================
+Found a 18 line (114 tokens) duplication in the following files:
+Starting at line 204 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+Starting at line 223 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+
+ .dataAcquisitionProjectId(project.getId())
+ .title(I18nString.builder().de("titel")
+ .en("title")
+ .build())
+ .fieldPeriod(Period.builder().start(LocalDate.now())
+ .end(LocalDate.now()
+ .plusDays(1))
+ .build())
+ .build();
+
+ // create the survey with the given id but with an unknown project
+ mockMvc.perform(put(API_SURVEYS_URI + "/" + survey.getId())
+ .content(TestUtil.convertObjectToJsonBytes(survey)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isBadRequest());
+ }
+
+ @Test
+ public void testCreateSurveyEmptyProject() throws Exception {
+=====================================================================
+Found a 19 line (114 tokens) duplication in the following files:
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/QInstrument.java
+Starting at line 26 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/QQuestion.java
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject _super = new eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject(this);
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("annotations"));
+
+ public final ListPath conceptIds = this.createList("conceptIds", String.class, StringPath.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("description"));
+=====================================================================
+Found a 6 line (114 tokens) duplication in the following files:
+Starting at line 145 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 164 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSearchDocument.java
+Starting at line 154 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+Starting at line 176 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableSearchDocument.java
+
+ public QInstrumentSearchDocument(Class extends InstrumentSearchDocument> type, PathMetadata metadata, PathInits inits) {
+ super(type, metadata, inits);
+ this.completeTitle = inits.isInitialized("completeTitle") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("completeTitle")) : null;
+ this.configuration = inits.isInitialized("configuration") ? new eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration(forProperty("configuration")) : null;
+ this.dataPackage = inits.isInitialized("dataPackage") ? new QDataPackageSubDocument(forProperty("dataPackage"), inits.get("dataPackage")) : null;
+ this.guiLabels = inits.isInitialized("guiLabels") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("guiLabels")) : null;
+=====================================================================
+Found a 10 line (113 tokens) duplication in the following files:
+Starting at line 88 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataSetSearchDocument.java
+Starting at line 81 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+
+ public final ListPath nestedInstruments = this.createList("nestedInstruments", InstrumentNestedDocument.class, QInstrumentNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedSurveys = this.createList("nestedSurveys", SurveyNestedDocument.class, QSurveyNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedVariables = this.createList("nestedVariables", VariableNestedDocument.class, QVariableNestedDocument.class, PathInits.DIRECT2);
+
+ //inherited
+ public final NumberPath number;
+=====================================================================
+Found a 17 line (111 tokens) duplication in the following files:
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSubDocument.java
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSubDocument.java
+
+ public static final QInstrumentSubDocument instrumentSubDocument = new QInstrumentSubDocument("instrumentSubDocument");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractRdcDomainObject _super = new eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractRdcDomainObject(this);
+
+ public final ListPath conceptIds = this.createList("conceptIds", String.class, StringPath.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description;
+=====================================================================
+Found a 10 line (108 tokens) duplication in the following files:
+Starting at line 72 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 81 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+
+ public final ListPath nestedInstruments = this.createList("nestedInstruments", InstrumentNestedDocument.class, QInstrumentNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedSurveys = this.createList("nestedSurveys", SurveyNestedDocument.class, QSurveyNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedVariables = this.createList("nestedVariables", VariableNestedDocument.class, QVariableNestedDocument.class, PathInits.DIRECT2);
+
+ //inherited
+ public final SetPath originalLanguages = _super.originalLanguages;
+=====================================================================
+Found a 14 line (107 tokens) duplication in the following files:
+Starting at line 219 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageAttachmentShadowCopyServiceTest.java
+Starting at line 219 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentShadowCopyServiceTest.java
+Starting at line 223 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentShadowCopyServiceTest.java
+Starting at line 221 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/service/QuestionImageShadowCopyServiceTest.java
+Starting at line 216 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/service/SurveyAttachmentShadowCopyServiceTest.java
+
+ gridFsMetadataUpdateService.store(is, filename, "text/plain", metadata);
+ is.close();
+ }
+
+ private void assertExpectedFilesExistence(List expectedFiles) {
+ Iterator it = gridFsOperations.find(new Query()).iterator();
+ List fileNames = new ArrayList<>();
+ while (it.hasNext()) {
+ fileNames.add(it.next().getFilename());
+ }
+ assertThat(fileNames.size(), equalTo(expectedFiles.size()));
+ assertThat(fileNames, containsInAnyOrder(expectedFiles.toArray()));
+ }
+}
+=====================================================================
+Found a 14 line (107 tokens) duplication in the following files:
+Starting at line 217 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 198 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+
+ "/api/data-sets/" + dataSetAttachmentMetadata.getDataSetId() + "/attachments"))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.[0].version", is(1)))
+ .andExpect(jsonPath("$.[0].createdBy", is("test")))
+ .andExpect(jsonPath("$.[0].lastModifiedBy", is("test")))
+ .andExpect(jsonPath("$.[0].language", is("en")));
+ }
+
+ @Test
+ @WithMockUser(authorities=AuthoritiesConstants.PUBLISHER)
+ public void testUploadAttachmentWithWrongLanguage() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+=====================================================================
+Found a 34 line (107 tokens) duplication in the following files:
+Starting at line 55 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 54 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResponseRateImageResourceTest.java
+
+ @Autowired
+ private ElasticsearchUpdateQueueItemRepository elasticsearchUpdateQueueItemRepository;
+
+ @Autowired
+ private ElasticsearchAdminService elasticsearchAdminService;
+
+ @Autowired
+ private JaversService javersService;
+
+ @Autowired
+ private GridFsOperations gridFsOperations;
+
+ @Autowired
+ private GridFsMetadataUpdateService gridFsMetadataUpdateService;
+
+ private MockMvc mockMvc;
+
+ @Before
+ public void setup() {
+ this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
+ .build();
+ }
+
+ @After
+ public void cleanUp() {
+ this.surveyRepository.deleteAll();
+ this.elasticsearchUpdateQueueItemRepository.deleteAll();
+ this.elasticsearchAdminService.recreateAllIndices();
+ javersService.deleteAll();
+ this.gridFsOperations.delete(new Query());
+ }
+
+ @Test
+ @WithMockUser(authorities=AuthoritiesConstants.PUBLISHER, username="test")
+=====================================================================
+Found a 16 line (106 tokens) duplication in the following files:
+Starting at line 21 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/QDataPackage.java
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/QDataSet.java
+Starting at line 20 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/QSurvey.java
+
+ public static final QDataPackage dataPackage = new QDataPackage("dataPackage");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject _super = new eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject(this);
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("annotations"));
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final ListPath dataCurators = this.createList("dataCurators", eu.dzhw.fdz.metadatamanagement.common.domain.Person.class, eu.dzhw.fdz.metadatamanagement.common.domain.QPerson.class, PathInits.DIRECT2);
+=====================================================================
+Found a 14 line (105 tokens) duplication in the following files:
+Starting at line 290 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+Starting at line 316 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+
+ public void testDeleteSurvey() throws Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ rdcProjectRepository.save(project);
+
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+
+ // create the survey with the given id
+ mockMvc.perform(put(API_SURVEYS_URI + "/" + survey.getId())
+ .content(TestUtil.convertObjectToJsonBytes(survey)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ // delete the survey
+ mockMvc.perform(delete(API_SURVEYS_URI + "/" + survey.getId()))
+ .andExpect(status().is2xxSuccessful());
+=====================================================================
+Found a 15 line (105 tokens) duplication in the following files:
+Starting at line 69 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 75 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public final StringPath lastModifiedBy = _super.lastModifiedBy;
+
+ //inherited
+ public final DateTimePath lastModifiedDate = _super.lastModifiedDate;
+
+ //inherited
+ public final StringPath masterId = _super.masterId;
+
+ public final ListPath nestedConcepts = this.createList("nestedConcepts", ConceptNestedDocument.class, QConceptNestedDocument.class, PathInits.DIRECT2);
+
+ public final QDataPackageNestedDocument nestedDataPackage;
+
+ public final ListPath nestedDataSets = this.createList("nestedDataSets", DataSetNestedDocument.class, QDataSetNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+=====================================================================
+Found a 18 line (104 tokens) duplication in the following files:
+Starting at line 85 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSearchDocument.java
+Starting at line 72 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString introduction = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.introduction);
+
+ //inherited
+ public final StringPath lastModifiedBy = _super.lastModifiedBy;
+
+ //inherited
+ public final DateTimePath lastModifiedDate = _super.lastModifiedDate;
+
+ //inherited
+ public final StringPath masterId = _super.masterId;
+
+ public final ListPath nestedConcepts = this.createList("nestedConcepts", ConceptNestedDocument.class, QConceptNestedDocument.class, PathInits.DIRECT2);
+
+ public final QDataPackageNestedDocument nestedDataPackage;
+
+ public final ListPath nestedDataSets = this.createList("nestedDataSets", DataSetNestedDocument.class, QDataSetNestedDocument.class, PathInits.DIRECT2);
+
+ public final QInstrumentNestedDocument nestedInstrument;
+=====================================================================
+Found a 14 line (103 tokens) duplication in the following files:
+Starting at line 103 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+Starting at line 797 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+
+ public void testCreateVariable() throws Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProjectRepository.save(project);
+
+ List surveyNumbers = new ArrayList<>();
+ surveyNumbers.add(1);
+
+ Variable variable =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "var1", 1, surveyNumbers);
+
+ // create the variable with the given id
+ mockMvc.perform(put(API_VARIABLES_URI + "/" + variable.getId())
+ .content(TestUtil.convertObjectToJsonBytes(variable))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+=====================================================================
+Found a 7 line (103 tokens) duplication in the following files:
+Starting at line 70 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 87 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public final ListPath nestedDataSets = this.createList("nestedDataSets", DataSetNestedDocument.class, QDataSetNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedInstruments = this.createList("nestedInstruments", InstrumentNestedDocument.class, QInstrumentNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedSurveys = this.createList("nestedSurveys", SurveyNestedDocument.class, QSurveyNestedDocument.class, PathInits.DIRECT2);
+=====================================================================
+Found a 7 line (103 tokens) duplication in the following files:
+Starting at line 72 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 88 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataSetSearchDocument.java
+Starting at line 119 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableSearchDocument.java
+
+ public final ListPath nestedInstruments = this.createList("nestedInstruments", InstrumentNestedDocument.class, QInstrumentNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedSurveys = this.createList("nestedSurveys", SurveyNestedDocument.class, QSurveyNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedVariables = this.createList("nestedVariables", VariableNestedDocument.class, QVariableNestedDocument.class, PathInits.DIRECT2);
+=====================================================================
+Found a 15 line (103 tokens) duplication in the following files:
+Starting at line 69 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 88 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSearchDocument.java
+
+ public final StringPath lastModifiedBy = _super.lastModifiedBy;
+
+ //inherited
+ public final DateTimePath lastModifiedDate = _super.lastModifiedDate;
+
+ //inherited
+ public final StringPath masterId = _super.masterId;
+
+ public final ListPath nestedConcepts = this.createList("nestedConcepts", ConceptNestedDocument.class, QConceptNestedDocument.class, PathInits.DIRECT2);
+
+ public final QDataPackageNestedDocument nestedDataPackage;
+
+ public final ListPath nestedDataSets = this.createList("nestedDataSets", DataSetNestedDocument.class, QDataSetNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+=====================================================================
+Found a 13 line (102 tokens) duplication in the following files:
+Starting at line 193 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 252 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 314 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 367 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+
+ surveyNumbers.add(1);
+ List listOfSurveyIds = new ArrayList<>();
+ listOfSurveyIds.add(survey.getId());
+
+ //Variables
+ Variable variable1 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name1", 1, surveyNumbers);
+ this.variableRepository.save(variable1);
+ Variable variable2 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name2", 2, surveyNumbers);
+ this.variableRepository.save(variable2);
+ Variable variable3 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name3", 3, surveyNumbers);
+=====================================================================
+Found a 18 line (101 tokens) duplication in the following files:
+Starting at line 93 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+Starting at line 248 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+
+ public void testCreateDataSet() throws Exception {
+
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ this.dataAcquisitionProjectRepository.save(project);
+
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+
+ DataSet dataSet = UnitTestCreateDomainObjectUtils.buildDataSet(project.getId(), survey.getId(), 1);
+
+ // Act and Assert
+ // create the variable with the given id
+ mockMvc.perform(put(API_DATASETS_URI + "/" + dataSet.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataSet)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ // check that auditing attributes have been set
+ mockMvc.perform(get(API_DATASETS_URI + "/" + dataSet.getId()))
+=====================================================================
+Found a 13 line (100 tokens) duplication in the following files:
+Starting at line 132 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageOverviewResource.java
+Starting at line 129 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetReportResource.java
+
+ @PathVariable("dataPackageId") String dataPackageId,
+ @RequestParam("onBehalfOf") String onBehalfOf, @PathVariable("language") String language)
+ throws IOException {
+ Optional user = userService.getUserWithAuthoritiesByLogin(onBehalfOf);
+ if (user.isPresent()) {
+ // TODO refactor this
+ User userInstance = user.get();
+ // switch to on behalf user for correct modification names
+ Collection extends GrantedAuthority> currentAuthorities =
+ SecurityContextHolder.getContext().getAuthentication().getAuthorities();
+ UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(
+ userInstance.getLogin(), userInstance.getPassword(), currentAuthorities);
+ SecurityContextHolder.getContext().setAuthentication(authentication);
+=====================================================================
+Found a 15 line (100 tokens) duplication in the following files:
+Starting at line 93 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+Starting at line 277 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+
+ public void testCreateDataSet() throws Exception {
+
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ this.dataAcquisitionProjectRepository.save(project);
+
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+
+ DataSet dataSet = UnitTestCreateDomainObjectUtils.buildDataSet(project.getId(), survey.getId(), 1);
+
+ // Act and Assert
+ // create the variable with the given id
+ mockMvc.perform(put(API_DATASETS_URI + "/" + dataSet.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataSet)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+=====================================================================
+Found a 16 line (99 tokens) duplication in the following files:
+Starting at line 74 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 101 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 133 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 177 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 59 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentVersionsResourceTest.java
+
+ public void testUploadValidAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ InstrumentAttachmentMetadata instrumentAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildInstrumentAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("instrumentAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(instrumentAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/instruments/attachments")
+ .file(attachment).file(metadata)).andExpect(status().isCreated());
+
+ // read the created attachment and check the version
+ mockMvc
+ .perform(get(
+ "/api/instruments/" + instrumentAttachmentMetadata.getInstrumentId() + "/attachments"))
+=====================================================================
+Found a 16 line (99 tokens) duplication in the following files:
+Starting at line 89 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 116 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 143 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 170 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 59 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentVersionsResourceTest.java
+
+ public void testUploadValidAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ SurveyAttachmentMetadata surveyAttachmentMetadata = UnitTestCreateDomainObjectUtils
+ .buildSurveyAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("surveyAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(surveyAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/surveys/attachments")
+ .file(attachment)
+ .file(metadata))
+ .andExpect(status().isCreated());
+
+ // read the created attachment and check the version
+ mockMvc.perform(
+ get("/api/surveys/" + surveyAttachmentMetadata.getSurveyId() + "/attachments"))
+=====================================================================
+Found a 13 line (99 tokens) duplication in the following files:
+Starting at line 382 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResourceTest.java
+Starting at line 414 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResourceTest.java
+
+ "alicejr@example.com", true, u.getLangKey(), u.getAuthorities(), false);
+
+ // Good user
+ restMvc.perform(post("/api/register").contentType(TestUtil.APPLICATION_JSON_UTF8)
+ .content(TestUtil.convertObjectToJsonBytes(u))).andExpect(status().isCreated());
+
+ // Duplicate login
+ restMvc
+ .perform(post("/api/register").contentType(TestUtil.APPLICATION_JSON_UTF8)
+ .content(TestUtil.convertObjectToJsonBytes(dup)))
+ .andExpect(status().is4xxClientError());
+
+ Optional userDup = userRepository.findOneByEmail("alicejr@example.com");
+=====================================================================
+Found a 14 line (99 tokens) duplication in the following files:
+Starting at line 72 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+Starting at line 72 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public final ListPath instruments = this.createList("instruments", InstrumentSubDocument.class, QInstrumentSubDocument.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath lastModifiedBy = _super.lastModifiedBy;
+
+ //inherited
+ public final DateTimePath lastModifiedDate = _super.lastModifiedDate;
+
+ //inherited
+ public final StringPath masterId = _super.masterId;
+
+ public final ListPath nestedConcepts = this.createList("nestedConcepts", ConceptNestedDocument.class, QConceptNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedDataSets = this.createList("nestedDataSets", DataSetNestedDocument.class, QDataSetNestedDocument.class, PathInits.DIRECT2);
+=====================================================================
+Found a 13 line (97 tokens) duplication in the following files:
+Starting at line 248 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+Starting at line 277 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+
+ public void testDeleteDataSet() throws JsonSyntaxException, IOException, Exception {
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ this.dataAcquisitionProjectRepository.save(project);
+
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+
+ DataSet dataSet = UnitTestCreateDomainObjectUtils.buildDataSet(project.getId(), survey.getId(), 1);
+
+ // create the DataSet with the given id
+ mockMvc.perform(put(API_DATASETS_URI + "/" + dataSet.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataSet)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+=====================================================================
+Found a 11 line (96 tokens) duplication in the following files:
+Starting at line 65 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/QDataSet.java
+Starting at line 64 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/QInstrument.java
+
+ public final ListPath subDataSets = this.createList("subDataSets", SubDataSet.class, QSubDataSet.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath successorId = _super.successorId;
+
+ public final ListPath surveyIds = this.createList("surveyIds", String.class, StringPath.class, PathInits.DIRECT2);
+
+ public final ListPath> surveyNumbers = this.>createList("surveyNumbers", Integer.class, NumberPath.class, PathInits.DIRECT2);
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString type = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("type"));
+=====================================================================
+Found a 13 line (95 tokens) duplication in the following files:
+Starting at line 89 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/relatedpublicationmanagement/rest/RelatedPublicationResourceControllerTest.java
+Starting at line 200 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/relatedpublicationmanagement/rest/RelatedPublicationResourceControllerTest.java
+Starting at line 235 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/relatedpublicationmanagement/rest/RelatedPublicationResourceControllerTest.java
+
+ public void testCreateRelatedPublications() throws IOException, Exception {
+ // ARRANGE
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProjectRepository.save(project);
+ DataPackage dataPackage = UnitTestCreateDomainObjectUtils.buildDataPackage(project.getId());
+ dataPackageRepository.save(dataPackage);
+ RelatedPublication relatedPublication =
+ UnitTestCreateDomainObjectUtils.buildRelatedPublication();
+ // ACT
+ // create the related publication with the given id
+ this.mockMvc.perform(put(API_RELATED_PUBLICATION_URI + "/" + relatedPublication.getId())
+ .content(TestUtil.convertObjectToJsonBytes(relatedPublication))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+=====================================================================
+Found a 13 line (94 tokens) duplication in the following files:
+Starting at line 89 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+Starting at line 75 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageVersionsResourceTest.java
+
+ public void testCreateDataPackage() throws IOException, Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProjectRepository.save(project);
+
+ DataPackage dataPackage = UnitTestCreateDomainObjectUtils.buildDataPackage(project.getId());
+
+ // create the dataPackage with the given id
+ mockMvc.perform(put(API_DATAPACKAGE_URI + "/" + dataPackage.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataPackage))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+
+ // read the dataPackage under the new url
+ mockMvc.perform(get(API_DATAPACKAGE_URI + "/" + dataPackage.getId()))
+=====================================================================
+Found a 35 line (94 tokens) duplication in the following files:
+Starting at line 26 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectLastReleaseResourceTest.java
+Starting at line 26 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectReleasesResourceTest.java
+
+public class DataAcquisitionProjectLastReleaseResourceTest extends AbstractTest {
+ private static final String API_DATA_ACQUISITION_PROJECTS_URI = "/api/data-acquisition-projects";
+
+ @Autowired
+ private WebApplicationContext wac;
+
+ @Autowired
+ private DataAcquisitionProjectRepository dataAcquisitionProjectRepository;
+
+ @Autowired
+ private ElasticsearchUpdateQueueItemRepository elasticsearchUpdateQueueItemRepository;
+
+ @Autowired
+ private ElasticsearchAdminService elasticsearchAdminService;
+
+ @Autowired
+ private JaversService javersService;
+
+ private MockMvc mockMvc;
+
+ @Before
+ public void setup() {
+ this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
+ }
+
+ @After
+ public void cleanUp() {
+ dataAcquisitionProjectRepository.deleteAll();
+ elasticsearchUpdateQueueItemRepository.deleteAll();
+ elasticsearchAdminService.recreateAllIndices();
+ javersService.deleteAll();
+ }
+
+ @Test
+ public void testFindReleases() throws IOException, Exception {
+=====================================================================
+Found a 9 line (94 tokens) duplication in the following files:
+Starting at line 64 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptNestedDocument.java
+Starting at line 70 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageNestedDocument.java
+Starting at line 76 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionNestedDocument.java
+Starting at line 66 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QRelatedPublicationNestedDocument.java
+Starting at line 74 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveyNestedDocument.java
+
+ public QConceptNestedDocument(Class extends ConceptNestedDocument> type, PathMetadata metadata, PathInits inits) {
+ super(type, metadata, inits);
+ this._super = new QAbstractNestedSubDocument(type, metadata, inits);
+ this.completeTitle = inits.isInitialized("completeTitle") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("completeTitle")) : null;
+ this.createdBy = _super.createdBy;
+ this.createdDate = _super.createdDate;
+ this.lastModifiedBy = _super.lastModifiedBy;
+ this.lastModifiedDate = _super.lastModifiedDate;
+ this.title = inits.isInitialized("title") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("title")) : null;
+=====================================================================
+Found a 19 line (94 tokens) duplication in the following files:
+Starting at line 36 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 40 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSearchDocument.java
+Starting at line 36 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableSearchDocument.java
+
+ public final ListPath concepts = this.createList("concepts", ConceptSubDocument.class, QConceptSubDocument.class, PathInits.DIRECT2);
+
+ public final eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration configuration;
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ //inherited
+ public final StringPath dataAcquisitionProjectId = _super.dataAcquisitionProjectId;
+
+ public final QDataPackageSubDocument dataPackage;
+
+ //inherited
+ public final StringPath dataPackageId = _super.dataPackageId;
+
+ public final ListPath dataSets = this.createList("dataSets", DataSetSubDocument.class, QDataSetSubDocument.class, PathInits.DIRECT2);
+=====================================================================
+Found a 36 line (92 tokens) duplication in the following files:
+Starting at line 39 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageVersionsResourceTest.java
+Starting at line 31 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/StudySeriesesResourceControllerTest.java
+
+ @Autowired
+ private WebApplicationContext wac;
+
+ @Autowired
+ private DataAcquisitionProjectRepository dataAcquisitionProjectRepository;
+
+ @Autowired
+ private DataPackageRepository dataPackageRepository;
+
+ @Autowired
+ private ElasticsearchUpdateQueueItemRepository elasticsearchUpdateQueueItemRepository;
+
+ @Autowired
+ private ElasticsearchAdminService elasticsearchAdminService;
+
+ @Autowired
+ private JaversService javersService;
+
+ private MockMvc mockMvc;
+
+ @Before
+ public void setup() {
+ this.mockMvc = MockMvcBuilders.webAppContextSetup(wac)
+ .build();
+ }
+
+ @After
+ public void cleanUp() {
+ dataAcquisitionProjectRepository.deleteAll();
+ dataPackageRepository.deleteAll();
+ elasticsearchUpdateQueueItemRepository.deleteAll();
+ elasticsearchAdminService.recreateAllIndices();
+ javersService.deleteAll();
+ }
+
+ @Test
+=====================================================================
+Found a 19 line (92 tokens) duplication in the following files:
+Starting at line 20 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/domain/QDaraUpdateQueueItem.java
+Starting at line 20 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/domain/QElasticsearchIndicesVersion.java
+
+ public static final QDaraUpdateQueueItem daraUpdateQueueItem = new QDaraUpdateQueueItem("daraUpdateQueueItem");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractRdcDomainObject _super = new eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractRdcDomainObject(this);
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath id = createString("id");
+
+ //inherited
+ public final StringPath lastModifiedBy = _super.lastModifiedBy;
+
+ //inherited
+ public final DateTimePath lastModifiedDate = _super.lastModifiedDate;
+
+ public final StringPath projectId = createString("projectId");
+=====================================================================
+Found a 16 line (91 tokens) duplication in the following files:
+Starting at line 146 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+Starting at line 186 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+Starting at line 262 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+
+ public void testUpdateInstrument() throws Exception {
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ this.dataAcquisitionProjectRepository.save(project);
+
+ Instrument instrument =
+ UnitTestCreateDomainObjectUtils.buildInstrument(project.getId(), project.getId() + "-sy1");
+
+ // Act and Assert
+ // create the instrument with the given id
+ mockMvc.perform(put(API_INSTRUMENTS_URI + "/" + instrument.getId())
+ .content(TestUtil.convertObjectToJsonBytes(instrument)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ // delete the survey
+ mockMvc.perform(delete(API_INSTRUMENTS_URI + "/" + instrument.getId()))
+=====================================================================
+Found a 16 line (91 tokens) duplication in the following files:
+Starting at line 26 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/QInstrument.java
+Starting at line 25 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSubDocument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("annotations"));
+
+ public final ListPath conceptIds = this.createList("conceptIds", String.class, StringPath.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("description"));
+=====================================================================
+Found a 12 line (90 tokens) duplication in the following files:
+Starting at line 93 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 137 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.conceptmanagement.domain.QTags tags = new eu.dzhw.fdz.metadatamanagement.conceptmanagement.domain.QTags(_super.tags);
+
+ // custom
+ // inherited
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString title = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.title);
+
+ public final ListPath variables = this.createList("variables", VariableSubDocument.class, QVariableSubDocument.class, PathInits.DIRECT2);
+
+ //inherited
+ public final NumberPath version = _super.version;
+
+ public QConceptSearchDocument(String variable) {
+=====================================================================
+Found a 13 line (89 tokens) duplication in the following files:
+Starting at line 136 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackagePublicListResourceControllerTest.java
+Starting at line 166 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackagePublicListResourceControllerTest.java
+
+ public void testReleasedDataPackageIsPubliclyVisible() throws IOException, Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProjectRepository.save(project);
+
+ DataPackage dataPackage = UnitTestCreateDomainObjectUtils.buildDataPackage(project.getId());
+
+ // create the dataPackage with the given id
+ mockMvc.perform(put(API_DATAPACKAGE_URI + "/" + dataPackage.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataPackage))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+
+ // release the project
+ project.setRelease(UnitTestCreateDomainObjectUtils.buildRelease());
+=====================================================================
+Found a 12 line (88 tokens) duplication in the following files:
+Starting at line 147 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 195 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 254 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 316 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+
+ this.instrumentRepository.save(instrument);
+
+ //Variables
+ Variable variable1 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name1", 1, surveyNumbers);
+ this.variableRepository.save(variable1);
+ Variable variable2 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name2", 2, surveyNumbers);
+ this.variableRepository.save(variable2);
+ Variable variable3 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name3", 3, surveyNumbers);
+ this.variableRepository.save(variable3);
+=====================================================================
+Found a 10 line (87 tokens) duplication in the following files:
+Starting at line 148 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackagePublicListResourceControllerTest.java
+Starting at line 179 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackagePublicListResourceControllerTest.java
+
+ project.setRelease(UnitTestCreateDomainObjectUtils.buildRelease());
+ mockMvc.perform(put("/api/data-acquisition-projects" + "/" + project.getId())
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(TestUtil.convertObjectToJsonBytes(project))).andExpect(status().isNoContent());
+ shadowCopyQueueItemService.executeShadowCopyActions();
+
+ UnitTestUserManagementUtils.logout();
+ // ensure that there are still no pinned data packages
+ mockMvc.perform(get(API_DATAPACKAGE_URI + "?pinned=true")).andExpect(status().isOk())
+ .andExpect(jsonPath("$.content.length()", is(0)));
+=====================================================================
+Found a 14 line (87 tokens) duplication in the following files:
+Starting at line 83 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+Starting at line 146 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+Starting at line 186 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+Starting at line 262 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentResourceControllerTest.java
+
+ public void testCreateInstrument() throws Exception {
+
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ this.dataAcquisitionProjectRepository.save(project);
+
+ Instrument instrument =
+ UnitTestCreateDomainObjectUtils.buildInstrument(project.getId(), project.getId() + "-sy1");
+
+ // Act and Assert
+ // create the instrument with the given id
+ mockMvc.perform(put(API_INSTRUMENTS_URI + "/" + instrument.getId())
+ .content(TestUtil.convertObjectToJsonBytes(instrument)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+=====================================================================
+Found a 12 line (86 tokens) duplication in the following files:
+Starting at line 240 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/mailmanagement/service/MailService.java
+Starting at line 268 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/mailmanagement/service/MailService.java
+
+ log.debug("Sending 'assignee group changed mail'");
+ }
+
+ users.parallelStream().forEach(user -> {
+ Locale locale = Locale.forLanguageTag(user.getLangKey());
+ Context context = new Context(locale);
+ context.setVariable("user", user);
+ context.setVariable("projectId", projectId);
+ context.setVariable("locale", locale);
+ context.setVariable("baseUrl", baseUrl);
+ context.setVariable("messageToGroup", StringUtils.trimWhitespace(message));
+ String content = templateEngine.process("assigneeGroupChanged", context);
+=====================================================================
+Found a 5 line (86 tokens) duplication in the following files:
+Starting at line 322 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+Starting at line 329 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+
+ mockMvc.perform(get(API_DATAPACKAGE_URI + "/" + dataPackage.getMasterId()))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.id", equalTo(dataPackage.getId())))
+ .andExpect(jsonPath("$.masterId", equalTo(dataPackage.getMasterId())))
+ .andExpect(jsonPath("$.release.version", equalTo("1.0.0")))
+ .andExpect(jsonPath("$.completeTitle").exists()).andExpect(jsonPath("$.doi").exists());
+=====================================================================
+Found a 7 line (86 tokens) duplication in the following files:
+Starting at line 120 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 109 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QRelatedPublicationSearchDocument.java
+
+ public QConceptSearchDocument(Class extends ConceptSearchDocument> type, PathMetadata metadata, PathInits inits) {
+ super(type, metadata, inits);
+ this.completeTitle = inits.isInitialized("completeTitle") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("completeTitle")) : null;
+ this.guiLabels = inits.isInitialized("guiLabels") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("guiLabels")) : null;
+ }
+
+}
+=====================================================================
+Found a 5 line (86 tokens) duplication in the following files:
+Starting at line 164 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+Starting at line 145 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 164 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSearchDocument.java
+Starting at line 154 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+Starting at line 176 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableSearchDocument.java
+
+ public QDataPackageSearchDocument(Class extends DataPackageSearchDocument> type, PathMetadata metadata, PathInits inits) {
+ super(type, metadata, inits);
+ this.completeTitle = inits.isInitialized("completeTitle") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("completeTitle")) : null;
+ this.configuration = inits.isInitialized("configuration") ? new eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration(forProperty("configuration")) : null;
+ this.guiLabels = inits.isInitialized("guiLabels") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("guiLabels")) : null;
+=====================================================================
+Found a 13 line (85 tokens) duplication in the following files:
+Starting at line 90 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 119 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 185 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 59 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentVersionsResourceTest.java
+
+ public void testUploadValidAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ DataSetAttachmentMetadata dataSetAttachmentMetadata = UnitTestCreateDomainObjectUtils
+ .buildDataSetAttachmentMetadata("projectid", 1);
+ MockMultipartFile metadata = new MockMultipartFile("dataSetAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(dataSetAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/data-sets/attachments")
+ .file(attachment)
+ .file(metadata))
+ .andExpect(status().isCreated());
+=====================================================================
+Found a 13 line (85 tokens) duplication in the following files:
+Starting at line 120 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentShadowCopyServiceTest.java
+Starting at line 120 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentShadowCopyServiceTest.java
+Starting at line 121 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/service/QuestionImageShadowCopyServiceTest.java
+
+ DataSetAttachmentMetadata shadow = createShadow(master, "1.0.0");
+ createTestFileForAttachment(shadow);
+
+ shadowCopyService.createShadowCopies(dataAcquisitionProject.getId(),
+ dataAcquisitionProject.getRelease(), "1.0.0");
+
+ List files = new ArrayList<>();
+ gridFsOperations.find(new Query()).forEach(files::add);
+
+ assertThat(files.size(), equalTo(2));
+
+ Query shadowQuery = new Query(GridFsCriteria.whereFilename()
+ .is("/data-sets/dat-" + PROJECT_ID + "-ds1$-1.0.0/attachments/filename.txt"));
+=====================================================================
+Found a 14 line (85 tokens) duplication in the following files:
+Starting at line 171 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 210 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 236 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+
+ public void testUpdateQuestion() throws Exception {
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ this.dataAcquisitionProjectRepository.save(project);
+
+ Question question = UnitTestCreateDomainObjectUtils
+ .buildQuestion(project.getId(), 123, "instrument-Id");
+ // Act and Assert
+ // create the variable with the given id
+ mockMvc.perform(put(API_QUESTIONS_URI + "/" + question.getId())
+ .content(TestUtil.convertObjectToJsonBytes(question)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ question.setQuestionText(I18nString.builder().de("Angepasst")
+=====================================================================
+Found a 8 line (84 tokens) duplication in the following files:
+Starting at line 332 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/mailmanagement/service/MailService.java
+Starting at line 411 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/mailmanagement/service/MailService.java
+
+ String subject = messageSource.getMessage("email.dataset-report-error.title",
+ new Object[] {errorNotification.getDomainObjectId()}, locale);
+ List adminAddresses = admins.stream().map(User::getEmail).collect(Collectors.toList());
+ sendEmail(sender, new String[] {onBehalfUser.getEmail()},
+ adminAddresses.toArray(new String[adminAddresses.size()]), null, subject, content, false,
+ true);
+
+ }
+=====================================================================
+Found a 25 line (84 tokens) duplication in the following files:
+Starting at line 42 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageShadowCopyServiceTest.java
+Starting at line 42 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentShadowCopyServiceTest.java
+Starting at line 47 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/service/QuestionShadowCopyServiceTest.java
+Starting at line 43 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/service/VariableShadowCopyServiceTest.java
+
+ private DataPackageShadowCopyService shadowCopyService;
+
+ @Autowired
+ private ElasticsearchUpdateQueueItemRepository elasticsearchUpdateQueueItemRepository;
+
+ @Autowired
+ private ElasticsearchAdminService elasticsearchAdminService;
+
+ private DataAcquisitionProject project;
+
+ private Release release;
+
+ @Before
+ public void setUp() {
+ release = new Release("1.0.0", LocalDateTime.now(), null, false);
+ DataAcquisitionProject releasedProject =
+ UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ releasedProject.setRelease(release);
+ project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ project.setRelease(release);
+ project.setId(PROJECT_ID);
+ }
+
+ @After
+ public void tearDown() {
+=====================================================================
+Found a 10 line (84 tokens) duplication in the following files:
+Starting at line 87 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageShadowCopyServiceTest.java
+Starting at line 92 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetShadowCopyServiceTest.java
+Starting at line 87 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentShadowCopyServiceTest.java
+Starting at line 77 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/service/DataAcquisitionProjectShadowCopyServiceTest.java
+Starting at line 93 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/service/QuestionShadowCopyServiceTest.java
+Starting at line 88 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/service/VariableShadowCopyServiceTest.java
+
+ DataPackage shadowCopy = shadowCopyOpt.get();
+
+ assertThat(shadowCopy.getId(), equalTo(master.getId() + "-" + release.getVersion()));
+ assertThat(shadowCopy.isShadow(), equalTo(true));
+ assertThat(shadowCopy.getSuccessorId(), equalTo(null));
+ assertThat(shadowCopy.getMasterId(), equalTo(master.getId()));
+ }
+
+ @Test
+ public void createShadowCopyWithSameReleaseVersion() {
+=====================================================================
+Found a 12 line (84 tokens) duplication in the following files:
+Starting at line 100 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionImageResourceTest.java
+Starting at line 119 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionImageResourceTest.java
+
+ new MockMultipartFile("image", "image.png", "image/png", "fakeimage".getBytes());
+ QuestionImageMetadata questionImageMetadata =
+ UnitTestCreateDomainObjectUtils.buildQuestionImageMetadata("projectid", "questionid");
+ questionImageMetadata.setQuestionId(questionImageMetadata.getQuestionId() + "-1.0.0");
+ questionImageMetadata.generateId();
+ MockMultipartFile metadata = new MockMultipartFile("questionImageMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(questionImageMetadata));
+
+ mockMvc
+ .perform(MockMvcRequestBuilders.multipart("/api/questions/images").file(attachment)
+ .file(metadata))
+ .andExpect(status().isBadRequest()).andExpect(jsonPath("$.errors[0].message",
+=====================================================================
+Found a 9 line (83 tokens) duplication in the following files:
+Starting at line 11 of /home/reitmann/data/metadatamanagement/node_modules/JSV/jsdoc-toolkit/java/src/JsDebugRun.java
+Starting at line 11 of /home/reitmann/data/metadatamanagement/node_modules/JSV/jsdoc-toolkit/java/src/JsRun.java
+
+public class JsDebugRun {
+ public static void main(String[] args) {
+ String[] jsargs = {"-j="+args[0]};
+
+ String[] allArgs = new String[jsargs.length + args.length];
+ System.arraycopy(args, 0, allArgs, 0, args.length);
+ System.arraycopy(jsargs, 0, allArgs, args.length ,jsargs.length);
+
+ org.mozilla.javascript.tools.debugger.Main.main(allArgs);
+=====================================================================
+Found a 10 line (83 tokens) duplication in the following files:
+Starting at line 204 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 217 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 198 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+
+ .perform(get("/api/concepts/" + conceptAttachmentMetadata.getConceptId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.[0].version", is(1)))
+ .andExpect(jsonPath("$.[0].createdBy", is("test")))
+ .andExpect(jsonPath("$.[0].lastModifiedBy", is("test")))
+ .andExpect(jsonPath("$.[0].language", is("en")));
+ }
+
+ @Test
+ @WithMockUser(authorities=AuthoritiesConstants.PUBLISHER)
+ public void testUploadAttachmentWithWrongType() throws Exception {
+=====================================================================
+Found a 11 line (83 tokens) duplication in the following files:
+Starting at line 89 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 119 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 185 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 59 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentVersionsResourceTest.java
+
+ public void testUploadValidAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+ DataPackageAttachmentMetadata dataPackageAttachmentMetadata =
+ UnitTestCreateDomainObjectUtils.buildDataPackageAttachmentMetadata("projectid");
+ MockMultipartFile metadata = new MockMultipartFile("dataPackageAttachmentMetadata", "Blob",
+ "application/json", TestUtil.convertObjectToJsonBytes(dataPackageAttachmentMetadata));
+
+ mockMvc.perform(MockMvcRequestBuilders.multipart("/api/data-packages/attachments")
+ .file(attachment).file(metadata)).andExpect(status().isCreated());
+=====================================================================
+Found a 13 line (83 tokens) duplication in the following files:
+Starting at line 89 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+Starting at line 217 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+Starting at line 75 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageVersionsResourceTest.java
+
+ public void testCreateDataPackage() throws IOException, Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProjectRepository.save(project);
+
+ DataPackage dataPackage = UnitTestCreateDomainObjectUtils.buildDataPackage(project.getId());
+
+ // create the dataPackage with the given id
+ mockMvc.perform(put(API_DATAPACKAGE_URI + "/" + dataPackage.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataPackage))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+
+ // read the dataPackage under the new url
+ mockMvc.perform(get(API_DATAPACKAGE_URI + "/" + dataPackage.getId()))
+=====================================================================
+Found a 13 line (83 tokens) duplication in the following files:
+Starting at line 88 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 171 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 210 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 236 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 312 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+
+ public void testCreateQuestion() throws Exception {
+
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ this.dataAcquisitionProjectRepository.save(project);
+
+ Question question = UnitTestCreateDomainObjectUtils
+ .buildQuestion(project.getId(), 123, "instrument-Id");
+ // Act and Assert
+ // create the Question with the given id
+ mockMvc.perform(put(API_QUESTIONS_URI + "/" + question.getId())
+ .content(TestUtil.convertObjectToJsonBytes(question)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+=====================================================================
+Found a 17 line (83 tokens) duplication in the following files:
+Starting at line 99 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/relatedpublicationmanagement/rest/RelatedPublicationResourceControllerTest.java
+Starting at line 125 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/relatedpublicationmanagement/rest/RelatedPublicationResourceControllerTest.java
+
+ this.mockMvc.perform(put(API_RELATED_PUBLICATION_URI + "/" + relatedPublication.getId())
+ .content(TestUtil.convertObjectToJsonBytes(relatedPublication))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+
+ // ASSERT
+ // read the related publication under the new url
+ this.mockMvc.perform(get(API_RELATED_PUBLICATION_URI + "/" + relatedPublication.getId()))
+ .andExpect(status().isOk());
+
+ elasticsearchUpdateQueueService.processAllQueueItems();
+
+ // check that there is one dataPackage and one publication document
+ assertThat(elasticsearchAdminService.countAllDocuments(), equalTo(2L));
+ }
+
+ @Test
+ public void testCreateRelatedPublicationsWithPost() throws IOException, Exception {
+=====================================================================
+Found a 11 line (83 tokens) duplication in the following files:
+Starting at line 65 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/QDataSet.java
+Starting at line 64 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/QInstrument.java
+Starting at line 92 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/QVariable.java
+
+ public final ListPath subDataSets = this.createList("subDataSets", SubDataSet.class, QSubDataSet.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath successorId = _super.successorId;
+
+ public final ListPath surveyIds = this.createList("surveyIds", String.class, StringPath.class, PathInits.DIRECT2);
+
+ public final ListPath> surveyNumbers = this.>createList("surveyNumbers", Integer.class, NumberPath.class, PathInits.DIRECT2);
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString type = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("type"));
+=====================================================================
+Found a 17 line (83 tokens) duplication in the following files:
+Starting at line 42 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataSetNestedDocument.java
+Starting at line 42 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentNestedDocument.java
+Starting at line 44 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableNestedDocument.java
+
+ public final StringPath lastModifiedBy;
+
+ //inherited
+ public final DateTimePath lastModifiedDate;
+
+ public final StringPath masterId = createString("masterId");
+
+ public final BooleanPath shadow = createBoolean("shadow");
+
+ public final StringPath successorId = createString("successorId");
+
+ public final ListPath surveyIds = this.createList("surveyIds", String.class, StringPath.class, PathInits.DIRECT2);
+
+ //inherited
+ public final NumberPath version;
+
+ public QDataSetNestedDocument(String variable) {
+=====================================================================
+Found a 12 line (82 tokens) duplication in the following files:
+Starting at line 41 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/helper/DataSetShadowCopyDataSource.java
+Starting at line 42 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/helper/InstrumentShadowCopyDataSource.java
+
+ DataSet copy = crudHelper.read(derivedId).orElseGet(DataSet::new);
+ BeanUtils.copyProperties(source, copy, "version");
+ copy.setId(derivedId);
+ copy.setDataAcquisitionProjectId(
+ source.getDataAcquisitionProjectId() + "-" + release.getVersion());
+ copy.setDataPackageId(source.getDataPackageId() + "-" + release.getVersion());
+ copy.setSurveyIds(createDerivedSurveyIds(source.getSurveyIds(), release.getVersion()));
+ return copy;
+ }
+
+ @Override
+ public Optional findPredecessorOfShadowCopy(DataSet shadowCopy, String previousVersion) {
+=====================================================================
+Found a 13 line (82 tokens) duplication in the following files:
+Starting at line 120 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageAttachmentShadowCopyServiceTest.java
+Starting at line 117 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/service/SurveyAttachmentShadowCopyServiceTest.java
+
+ DataPackageAttachmentMetadata shadow = createShadow(master, "1.0.0");
+ createTestFileForAttachment(shadow);
+
+ shadowCopyService.createShadowCopies(dataAcquisitionProject.getId(),
+ dataAcquisitionProject.getRelease(), "1.0.0");
+
+ List files = new ArrayList<>();
+ gridFsOperations.find(new Query()).iterator().forEachRemaining(files::add);
+
+ assertThat(files.size(), equalTo(2));
+
+ Query shadowQuery = new Query(GridFsCriteria.whereFilename()
+ .is("/data-packages/stu-" + PROJECT_ID + "$-1.0.0/attachments/filename.txt"));
+=====================================================================
+Found a 11 line (82 tokens) duplication in the following files:
+Starting at line 79 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentShadowCopyServiceTest.java
+Starting at line 79 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentShadowCopyServiceTest.java
+Starting at line 75 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/service/SurveyAttachmentShadowCopyServiceTest.java
+
+ UnitTestCreateDomainObjectUtils.buildDataSetAttachmentMetadata(PROJECT_ID, 1);
+ master.generateId();
+ master.setMasterId(master.getId());
+ createTestFileForAttachment(master);
+
+ shadowCopyService.createShadowCopies(dataAcquisitionProject.getId(),
+ dataAcquisitionProject.getRelease(), null);
+
+ GridFSFile gridFsFile = gridFsOperations.findOne(
+ new Query(GridFsCriteria.whereMetaData("dataAcquisitionProjectId").is(PROJECT_ID + "-1.0.0")
+ .andOperator(GridFsCriteria.whereMetaData("shadow").is(true))));
+=====================================================================
+Found a 11 line (82 tokens) duplication in the following files:
+Starting at line 60 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectLastReleaseResourceTest.java
+Starting at line 60 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectReleasesResourceTest.java
+
+ public void testFindReleases() throws IOException, Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ project = dataAcquisitionProjectRepository.save(project);
+
+ // assert that there are no releases yet
+ mockMvc.perform(get(API_DATA_ACQUISITION_PROJECTS_URI + "/" + project.getId() + "/releases"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(0)));
+
+ // fake a release
+ project.setRelease(UnitTestCreateDomainObjectUtils.buildRelease());
+ dataAcquisitionProjectRepository.save(project);
+=====================================================================
+Found a 12 line (82 tokens) duplication in the following files:
+Starting at line 93 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 137 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+Starting at line 127 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.conceptmanagement.domain.QTags tags = new eu.dzhw.fdz.metadatamanagement.conceptmanagement.domain.QTags(_super.tags);
+
+ // custom
+ // inherited
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString title = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.title);
+
+ public final ListPath variables = this.createList("variables", VariableSubDocument.class, QVariableSubDocument.class, PathInits.DIRECT2);
+
+ //inherited
+ public final NumberPath version = _super.version;
+
+ public QConceptSearchDocument(String variable) {
+=====================================================================
+Found a 15 line (82 tokens) duplication in the following files:
+Starting at line 35 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+Starting at line 36 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 40 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSearchDocument.java
+
+ public final ListPath concepts = this.createList("concepts", ConceptSubDocument.class, QConceptSubDocument.class, PathInits.DIRECT2);
+
+ public final eu.dzhw.fdz.metadatamanagement.projectmanagement.domain.QConfiguration configuration;
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ //inherited
+ public final StringPath dataAcquisitionProjectId = _super.dataAcquisitionProjectId;
+
+ //inherited
+ public final ListPath dataCurators = _super.dataCurators;
+=====================================================================
+Found a 12 line (81 tokens) duplication in the following files:
+Starting at line 76 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/helper/DataSetShadowCopyDataSource.java
+Starting at line 78 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/helper/InstrumentShadowCopyDataSource.java
+
+ .filter(shadowCopy -> !dataSetRepository.existsById(shadowCopy.getMasterId()));
+ }
+
+ private static List createDerivedSurveyIds(List surveyIds, String version) {
+ return surveyIds.stream().map(surveyId -> surveyId + "-" + version)
+ .collect(Collectors.toList());
+ }
+
+ @Override
+ public void deleteExistingShadowCopies(String projectId, String version) {
+ String oldProjectId = projectId + "-" + version;
+ try (Stream dataSets = dataSetRepository
+=====================================================================
+Found a 7 line (81 tokens) duplication in the following files:
+Starting at line 40 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/DataSetSearchDocument.java
+Starting at line 43 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/SurveySearchDocument.java
+
+ private List variables = new ArrayList<>();
+ private List nestedVariables = new ArrayList<>();
+ private List instruments = new ArrayList<>();
+ private List nestedInstruments = new ArrayList<>();
+ private List questions = new ArrayList<>();
+ private List nestedQuestions = new ArrayList<>();
+ private List surveys = new ArrayList<>();
+=====================================================================
+Found a 13 line (81 tokens) duplication in the following files:
+Starting at line 86 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+Starting at line 290 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+Starting at line 316 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+
+ public void testCreateValidSurvey() throws Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ rdcProjectRepository.save(project);
+
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+
+ // create the survey with the given id
+ mockMvc.perform(put(API_SURVEYS_URI + "/" + survey.getId())
+ .content(TestUtil.convertObjectToJsonBytes(survey)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ // read the survey under the new url
+ mockMvc.perform(get(API_SURVEYS_URI + "/" + survey.getId()))
+=====================================================================
+Found a 14 line (81 tokens) duplication in the following files:
+Starting at line 227 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResourceTest.java
+Starting at line 253 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/usermanagement/rest/AccountResourceTest.java
+
+ public void testFinishPasswordReset() throws Exception {
+
+ // Arrange
+ User user = UnitTestUserManagementUtils.getDefaultUser();
+ user.setPassword("sdkgfsdkkgfsdglkfglsdjkagfjklsdgfhklsdglkfglksdgslkfgsdklj12");
+ user.setActivationKey("testActivateTrue");
+ user.setActivated(true);
+ user.setResetKey("ActivationKey");
+ user.setResetDate(LocalDateTime.now().minusHours(1L));
+ this.userRepository.save(user);
+
+ KeyAndPasswordDto dto = new KeyAndPasswordDto();
+ dto.setKey(user.getResetKey());
+ dto.setNewPassword("newPassword");
+=====================================================================
+Found a 17 line (81 tokens) duplication in the following files:
+Starting at line 25 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/QDataSet.java
+Starting at line 22 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/QSurvey.java
+Starting at line 25 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/domain/QVariable.java
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject _super = new eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject(this);
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("annotations"));
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("description"));
+=====================================================================
+Found a 16 line (81 tokens) duplication in the following files:
+Starting at line 28 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/QDataSet.java
+Starting at line 28 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/QInstrument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("annotations"));
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("description"));
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString format;
+=====================================================================
+Found a 10 line (81 tokens) duplication in the following files:
+Starting at line 41 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 51 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+
+ public final ListPath dataPackages = this.createList("dataPackages", DataPackageSubDocument.class, QDataPackageSubDocument.class, PathInits.DIRECT2);
+
+ public final ListPath dataSets = this.createList("dataSets", DataSetSubDocument.class, QDataSetSubDocument.class, PathInits.DIRECT2);
+
+ // custom
+ // inherited
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(_super.description);
+
+ //inherited
+ public final StringPath doi = _super.doi;
+=====================================================================
+Found a 20 line (80 tokens) duplication in the following files:
+Starting at line 93 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageAttachmentService.java
+Starting at line 154 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageAttachmentService.java
+
+ + Pattern.quote(DataPackageAttachmentFilenameBuilder.buildFileNamePrefix(dataPackageId))));
+ Iterable files = this.operations.find(query);
+ files.forEach(file -> {
+ DataPackageAttachmentMetadata metadata = mongoTemplate.getConverter()
+ .read(DataPackageAttachmentMetadata.class, file.getMetadata());
+ if (metadata.isShadow()) {
+ throw new ShadowCopyDeleteNotAllowedException();
+ }
+ javers.commitShallowDelete(currentUser, metadata);
+ });
+ this.operations.delete(query);
+ }
+
+ /**
+ * Load all metadata objects from gridfs (ordered by indexInDataPackage).
+ *
+ * @param dataPackageId The id of the dataPackage.
+ * @return A list of metadata.
+ */
+ public List findAllByDataPackage(String dataPackageId) {
+=====================================================================
+Found a 20 line (80 tokens) duplication in the following files:
+Starting at line 96 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentService.java
+Starting at line 165 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentService.java
+
+ "^" + Pattern.quote(DataSetAttachmentFilenameBuilder.buildFileNamePrefix(dataSetId))));
+ Iterable files = this.operations.find(query);
+ files.forEach(file -> {
+ DataSetAttachmentMetadata metadata =
+ mongoTemplate.getConverter().read(DataSetAttachmentMetadata.class, file.getMetadata());
+ if (metadata.isShadow()) {
+ throw new ShadowCopyDeleteNotAllowedException();
+ }
+ javers.commitShallowDelete(currentUser, metadata);
+ });
+ this.operations.delete(query);
+ }
+
+ /**
+ * Load all metadata objects from gridfs (ordered by indexInDataSet).
+ *
+ * @param dataSetId The id of the dataSet.
+ * @return A list of metadata.
+ */
+ public List findAllByDataSet(String dataSetId) {
+=====================================================================
+Found a 20 line (80 tokens) duplication in the following files:
+Starting at line 89 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentService.java
+Starting at line 158 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentService.java
+
+ + Pattern.quote(InstrumentAttachmentFilenameBuilder.buildFileNamePrefix(instrumentId))));
+ Iterable files = this.operations.find(query);
+ files.forEach(file -> {
+ InstrumentAttachmentMetadata metadata =
+ mongoTemplate.getConverter().read(InstrumentAttachmentMetadata.class, file.getMetadata());
+ if (metadata.isShadow()) {
+ throw new ShadowCopyDeleteNotAllowedException();
+ }
+ javers.commitShallowDelete(currentUser, metadata);
+ });
+ this.operations.delete(query);
+ }
+
+ /**
+ * Load all metadata objects from gridfs (ordered by indexInInstrument).
+ *
+ * @param instrumentId The id of the instrument.
+ * @return A list of metadata.
+ */
+ public List findAllByInstrument(String instrumentId) {
+=====================================================================
+Found a 11 line (80 tokens) duplication in the following files:
+Starting at line 147 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 369 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+
+ this.instrumentRepository.save(instrument);
+
+ //Variables
+ Variable variable1 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name1", 1, surveyNumbers);
+ this.variableRepository.save(variable1);
+ Variable variable2 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name2", 2, surveyNumbers);
+ this.variableRepository.save(variable2);
+ Variable variable3 =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "name3", 3, surveyNumbers);
+=====================================================================
+Found a 13 line (80 tokens) duplication in the following files:
+Starting at line 48 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/QDataSet.java
+Starting at line 43 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataSetSubDocument.java
+
+ public final StringPath id = createString("id");
+
+ public final ListPath languages = this.createList("languages", String.class, StringPath.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath lastModifiedBy = _super.lastModifiedBy;
+
+ //inherited
+ public final DateTimePath lastModifiedDate = _super.lastModifiedDate;
+
+ public final StringPath masterId = createString("masterId");
+
+ public final NumberPath number = createNumber("number", Integer.class);
+=====================================================================
+Found a 7 line (80 tokens) duplication in the following files:
+Starting at line 64 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptNestedDocument.java
+Starting at line 70 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageNestedDocument.java
+Starting at line 74 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataSetNestedDocument.java
+Starting at line 74 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentNestedDocument.java
+Starting at line 76 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionNestedDocument.java
+Starting at line 66 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QRelatedPublicationNestedDocument.java
+Starting at line 74 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveyNestedDocument.java
+Starting at line 76 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableNestedDocument.java
+
+ public QConceptNestedDocument(Class extends ConceptNestedDocument> type, PathMetadata metadata, PathInits inits) {
+ super(type, metadata, inits);
+ this._super = new QAbstractNestedSubDocument(type, metadata, inits);
+ this.completeTitle = inits.isInitialized("completeTitle") ? new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("completeTitle")) : null;
+ this.createdBy = _super.createdBy;
+ this.createdDate = _super.createdDate;
+ this.lastModifiedBy = _super.lastModifiedBy;
+=====================================================================
+Found a 11 line (79 tokens) duplication in the following files:
+Starting at line 284 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchUpdateQueueService.java
+Starting at line 378 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/service/ElasticsearchUpdateQueueService.java
+
+ List dataPackageSubDocuments =
+ dataPackages.stream().map(dataPackage -> {
+ DataAcquisitionProject project =
+ projectRepository.findById(dataPackage.getDataAcquisitionProjectId()).orElse(null);
+ if (project == null) {
+ // project has been deleted, skip upsert
+ return null;
+ }
+ return new DataPackageSubDocument(dataPackage,
+ doiBuilder.buildDataPackageDoi(dataPackage, getRelease(project)));
+ }).filter(document -> document != null).collect(Collectors.toList());
+=====================================================================
+Found a 17 line (79 tokens) duplication in the following files:
+Starting at line 45 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentVersionsResourceTest.java
+Starting at line 45 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentVersionsResourceTest.java
+Starting at line 45 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentVersionsResourceTest.java
+Starting at line 45 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentVersionsResourceTest.java
+Starting at line 45 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentVersionsResourceTest.java
+
+ private MockMvc mockMvc;
+
+ @Before
+ public void setup() {
+ this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
+ }
+
+ @After
+ public void cleanUp() {
+ javersService.deleteAll();
+ this.gridFsOperations.delete(new Query());
+ }
+
+ @Test
+ public void testUploadValidAttachmentAndCheckVersion() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+=====================================================================
+Found a 15 line (79 tokens) duplication in the following files:
+Starting at line 70 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAccessWaysResourceControllerTest.java
+Starting at line 58 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/StudySeriesesResourceControllerTest.java
+
+ surveyRepository.deleteAll();
+ dataPackageRepository.deleteAll();
+ elasticsearchUpdateQueueItemRepository.deleteAll();
+ elasticsearchAdminService.recreateAllIndices();
+ javersService.deleteAll();
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER)
+ public void testGetAccessWaysOfDataPackage() throws IOException, Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProjectRepository.save(project);
+
+ DataPackage dataPackage = UnitTestCreateDomainObjectUtils.buildDataPackage(project.getId());
+ dataPackageRepository.save(dataPackage);
+=====================================================================
+Found a 10 line (79 tokens) duplication in the following files:
+Starting at line 114 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackagePublicListResourceControllerTest.java
+Starting at line 136 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackagePublicListResourceControllerTest.java
+Starting at line 166 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackagePublicListResourceControllerTest.java
+Starting at line 89 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+Starting at line 186 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+Starting at line 217 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+Starting at line 75 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageVersionsResourceTest.java
+
+ public void testUnreleasedNotPubliclyVisible() throws IOException, Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProjectRepository.save(project);
+
+ DataPackage dataPackage = UnitTestCreateDomainObjectUtils.buildDataPackage(project.getId());
+
+ // create the dataPackage with the given id
+ mockMvc.perform(put(API_DATAPACKAGE_URI + "/" + dataPackage.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataPackage))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+=====================================================================
+Found a 21 line (79 tokens) duplication in the following files:
+Starting at line 52 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentShadowCopyServiceTest.java
+Starting at line 53 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/service/QuestionImageShadowCopyServiceTest.java
+
+ private InstrumentAttachmentShadowCopyService shadowCopyService;
+
+ @Autowired
+ private GridFsMetadataUpdateService gridFsMetadataUpdateService;
+
+ private DataAcquisitionProject dataAcquisitionProject;
+
+ private Release release;
+
+ @Before
+ public void setup() {
+ release = new Release("1.0.0", LocalDateTime.now(), null, false);
+
+ dataAcquisitionProject = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProject.setId(PROJECT_ID);
+ dataAcquisitionProject.setRelease(release);
+ }
+
+ @After
+ public void teardown() {
+ Query query = new Query(GridFsCriteria.whereFilename().regex("^/instruments"));
+=====================================================================
+Found a 11 line (79 tokens) duplication in the following files:
+Starting at line 158 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectVersionsResourceTest.java
+Starting at line 168 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectVersionsResourceTest.java
+
+ project.setRelease(UnitTestCreateDomainObjectUtils.buildRelease());
+ this.mockMvc.perform(put(API_DATA_ACQUISITION_PROJECTS_URI + "/" + project.getId())
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(TestUtil.convertObjectToJsonBytes(project))).andExpect(status().isNoContent());
+
+ // Assert that the last version is 1.0.0
+ lastRelease = this.versionsService.findLastRelease(project.getId());
+ assertThat(lastRelease.getVersion(), is("1.0.0"));
+
+ // Save third time without release (simulates unrelease)
+ project.setRelease(null);
+=====================================================================
+Found a 13 line (79 tokens) duplication in the following files:
+Starting at line 397 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+Starting at line 429 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+
+ public void testCreateVariableWithNonUniqueValueClass() throws Exception {
+
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProjectRepository.save(project);
+
+ List surveyNumbers = new ArrayList<>();
+ surveyNumbers.add(1);
+
+ Variable variable =
+ UnitTestCreateDomainObjectUtils.buildVariable(project.getId(), 1, "var1", 1, surveyNumbers);
+ ValidResponse validResponse = variable.getDistribution().getValidResponses().get(0);
+ validResponse.setValue("123.456");
+=====================================================================
+Found a 7 line (79 tokens) duplication in the following files:
+Starting at line 95 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+Starting at line 90 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataSetSearchDocument.java
+Starting at line 83 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+
+ public final ListPath nestedSponsors = this.createList("nestedSponsors", eu.dzhw.fdz.metadatamanagement.common.domain.I18nString.class, eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString.class, PathInits.DIRECT2);
+
+ public final ListPath nestedSurveys = this.createList("nestedSurveys", SurveyNestedDocument.class, QSurveyNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedVariables = this.createList("nestedVariables", VariableNestedDocument.class, QVariableNestedDocument.class, PathInits.DIRECT2);
+
+ public final NumberPath numberOfWaves = createNumber("numberOfWaves", Integer.class);
+=====================================================================
+Found a 13 line (78 tokens) duplication in the following files:
+Starting at line 70 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 80 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 81 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+
+ this.conceptRepository.deleteAll();
+ this.elasticsearchUpdateQueueItemRepository.deleteAll();
+ this.elasticsearchAdminService.recreateAllIndices();
+ this.javersService.deleteAll();
+ this.gridFsOperations.delete(new Query());
+ }
+
+ @Test
+ @WithMockUser(authorities=AuthoritiesConstants.PUBLISHER, username="test")
+ public void testUploadValidAttachment() throws Exception {
+
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+=====================================================================
+Found a 11 line (78 tokens) duplication in the following files:
+Starting at line 79 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageAttachmentShadowCopyServiceTest.java
+Starting at line 79 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentShadowCopyServiceTest.java
+Starting at line 79 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentShadowCopyServiceTest.java
+Starting at line 80 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/service/QuestionImageShadowCopyServiceTest.java
+Starting at line 75 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/service/SurveyAttachmentShadowCopyServiceTest.java
+
+ UnitTestCreateDomainObjectUtils.buildDataPackageAttachmentMetadata(PROJECT_ID);
+ master.generateId();
+ master.setMasterId(master.getId());
+ createTestFileForAttachment(master);
+
+ shadowCopyService.createShadowCopies(dataAcquisitionProject.getId(),
+ dataAcquisitionProject.getRelease(), null);
+
+ GridFSFile gridFsFile = gridFsOperations.findOne(
+ new Query(GridFsCriteria.whereMetaData("dataAcquisitionProjectId").is(PROJECT_ID + "-1.0.0")
+ .andOperator(GridFsCriteria.whereMetaData("shadow").is(true))));
+=====================================================================
+Found a 9 line (78 tokens) duplication in the following files:
+Starting at line 139 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 155 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+
+ mockMvc.perform(get(API_QUESTIONS_URI + "/" + question.getId())).andExpect(status().isOk())
+ .andExpect(jsonPath("$.createdDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.lastModifiedDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.createdBy", is("user")))
+ .andExpect(jsonPath("$.lastModifiedBy", is("user")));
+ }
+
+ @Test
+ public void testDeleteQuestion() throws Exception {
+=====================================================================
+Found a 15 line (78 tokens) duplication in the following files:
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySubDocument.java
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableSubDocument.java
+
+ public static final QSurveySubDocument surveySubDocument = new QSurveySubDocument("surveySubDocument");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractRdcDomainObject _super = new eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractRdcDomainObject(this);
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString dataType;
+=====================================================================
+Found a 16 line (77 tokens) duplication in the following files:
+Starting at line 26 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/QInstrument.java
+Starting at line 25 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QQuestionSubDocument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("annotations"));
+
+ public final ListPath conceptIds = this.createList("conceptIds", String.class, StringPath.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString description = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("description"));
+=====================================================================
+Found a 16 line (77 tokens) duplication in the following files:
+Starting at line 29 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/domain/QQuestion.java
+Starting at line 25 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSubDocument.java
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("annotations"));
+
+ public final ListPath conceptIds = this.createList("conceptIds", String.class, StringPath.class, PathInits.DIRECT2);
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+
+ //inherited
+ public final DateTimePath createdDate = _super.createdDate;
+
+ public final StringPath dataAcquisitionProjectId = createString("dataAcquisitionProjectId");
+
+ public final StringPath dataPackageId = createString("dataPackageId");
+
+ //inherited
+ public final BooleanPath hidden = _super.hidden;
+=====================================================================
+Found a 7 line (77 tokens) duplication in the following files:
+Starting at line 70 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 87 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+Starting at line 87 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QSurveySearchDocument.java
+
+ public final ListPath nestedDataSets = this.createList("nestedDataSets", DataSetNestedDocument.class, QDataSetNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedInstruments = this.createList("nestedInstruments", InstrumentNestedDocument.class, QInstrumentNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedSurveys = this.createList("nestedSurveys", SurveyNestedDocument.class, QSurveyNestedDocument.class, PathInits.DIRECT2);
+=====================================================================
+Found a 7 line (77 tokens) duplication in the following files:
+Starting at line 81 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QInstrumentSearchDocument.java
+Starting at line 119 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QVariableSearchDocument.java
+
+ public final ListPath nestedDataSets = this.createList("nestedDataSets", DataSetNestedDocument.class, QDataSetNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedSurveys = this.createList("nestedSurveys", SurveyNestedDocument.class, QSurveyNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedVariables = this.createList("nestedVariables", VariableNestedDocument.class, QVariableNestedDocument.class, PathInits.DIRECT2);
+=====================================================================
+Found a 6 line (76 tokens) duplication in the following files:
+Starting at line 115 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptVersionsResourceTest.java
+Starting at line 137 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptVersionsResourceTest.java
+
+ .andExpect(jsonPath("$[0].version", is(equalTo(2))))
+ .andExpect(jsonPath("$[0].authors.length()", is(equalTo(concept.getAuthors().size()))))
+ .andExpect(
+ jsonPath("$[0].authors[0].firstName", is(concept.getAuthors().get(0).getFirstName())))
+ .andExpect(jsonPath("$[1].id", is(concept.getId())))
+ .andExpect(jsonPath("$[1].title.de", is("hurzDe2")))
+=====================================================================
+Found a 7 line (76 tokens) duplication in the following files:
+Starting at line 131 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageVersionsResourceTest.java
+Starting at line 157 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageVersionsResourceTest.java
+
+ .andExpect(jsonPath("$[0].version", is(equalTo(2))))
+ .andExpect(jsonPath("$[0].projectContributors.length()",
+ is(equalTo(dataPackage.getProjectContributors().size()))))
+ .andExpect(jsonPath("$[0].projectContributors[0].firstName",
+ is(dataPackage.getProjectContributors().get(0).getFirstName())))
+ .andExpect(jsonPath("$[1].id", is(dataPackage.getId())))
+ .andExpect(jsonPath("$[1].title.de", is("hurzDe2")))
+=====================================================================
+Found a 10 line (76 tokens) duplication in the following files:
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageAttachmentShadowCopyServiceTest.java
+Starting at line 152 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentShadowCopyServiceTest.java
+Starting at line 155 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentShadowCopyServiceTest.java
+Starting at line 153 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/service/QuestionImageShadowCopyServiceTest.java
+Starting at line 149 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/service/SurveyAttachmentShadowCopyServiceTest.java
+
+ DataPackageAttachmentMetadata shadow = createShadow(master, "1.0.0");
+ createTestFileForAttachment(shadow);
+ release.setVersion("1.0.1");
+
+ shadowCopyService.createShadowCopies(dataAcquisitionProject.getId(),
+ dataAcquisitionProject.getRelease(), "1.0.0");
+
+ GridFSFile gridFsFile = gridFsOperations.findOne(
+ new Query(GridFsCriteria.whereMetaData("dataAcquisitionProjectId").is(PROJECT_ID + "-1.0.0")
+ .andOperator(GridFsCriteria.whereMetaData("shadow").is(true))));
+=====================================================================
+Found a 13 line (76 tokens) duplication in the following files:
+Starting at line 122 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+Starting at line 353 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectPostValidationResourceTest.java
+
+ private DataAcquisitionProject buildValidProject() {
+ //Arrange
+ //Project
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ project.getConfiguration().setDataPackagesState(new ProjectState(true, true));
+ this.rdcProjectRepository.save(project);
+
+ //Survey
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+ this.surveyRepository.save(survey);
+ List surveyNumbers = new ArrayList<>();
+ surveyNumbers.add(1);
+ List listOfSurveyIds = new ArrayList<>();
+=====================================================================
+Found a 9 line (76 tokens) duplication in the following files:
+Starting at line 86 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectResourceControllerTest.java
+Starting at line 154 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectResourceControllerTest.java
+
+ public void testCreateDataAcquisitionProject() throws IOException, Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ // create the project with the given id
+ mockMvc.perform(put(API_DATA_ACQUISITION_PROJECTS_URI + "/" + project.getId())
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(TestUtil.convertObjectToJsonBytes(project))).andExpect(status().isCreated());
+
+ // read the project under the new url
+ mockMvc.perform(get(API_DATA_ACQUISITION_PROJECTS_URI + "/" + project.getId()))
+=====================================================================
+Found a 10 line (75 tokens) duplication in the following files:
+Starting at line 86 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptResourceControllerTest.java
+Starting at line 68 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptVersionsResourceTest.java
+
+ public void testCreateConcept() throws IOException, Exception {
+ Concept concept = UnitTestCreateDomainObjectUtils.buildConcept();
+
+ // create the concept with the given id
+ mockMvc.perform(put(API_CONCEPT_URI + "/" + concept.getId())
+ .content(TestUtil.convertObjectToJsonBytes(concept))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+
+ // read the concept under the new url
+ mockMvc.perform(get(API_CONCEPT_URI + "/" + concept.getId())).andExpect(status().isOk());
+=====================================================================
+Found a 12 line (75 tokens) duplication in the following files:
+Starting at line 120 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 147 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+
+ public void testCreateQuestionWithPost() throws Exception {
+
+ // Arrange
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ this.dataAcquisitionProjectRepository.save(project);
+
+ Question question =
+ UnitTestCreateDomainObjectUtils.buildQuestion(project.getId(), 123, "instrument-Id");
+ // Act and Assert
+ // create the Question with the given id
+ mockMvc.perform(post(API_QUESTIONS_URI).content(TestUtil.convertObjectToJsonBytes(question))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+=====================================================================
+Found a 8 line (75 tokens) duplication in the following files:
+Starting at line 74 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QConceptSearchDocument.java
+Starting at line 95 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/documents/QDataPackageSearchDocument.java
+
+ public final ListPath nestedQuestions = this.createList("nestedQuestions", QuestionNestedDocument.class, QQuestionNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedSurveys = this.createList("nestedSurveys", SurveyNestedDocument.class, QSurveyNestedDocument.class, PathInits.DIRECT2);
+
+ public final ListPath nestedVariables = this.createList("nestedVariables", VariableNestedDocument.class, QVariableNestedDocument.class, PathInits.DIRECT2);
+
+ //inherited
+ public final SetPath originalLanguages = _super.originalLanguages;
+=====================================================================
+Found a 8 line (74 tokens) duplication in the following files:
+Starting at line 57 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/repository/DaraUpdateQueueItemRepositoryImpl.java
+Starting at line 45 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/searchmanagement/repository/ElasticsearchUpdateQueueItemRepositoryImpl.java
+
+ public List findOldestLockedItems(String updateStartedBy,
+ LocalDateTime updateStartedAt) {
+ Query query = new Query(new Criteria().andOperator(Criteria.where("updateStartedBy")
+ .is(updateStartedBy),
+ Criteria.where("updateStartedAt")
+ .is(updateStartedAt))).limit(BULK_SIZE)
+ .with(Sort.by(Direction.ASC, "createdDate"));
+ return mongoOperations.find(query, DaraUpdateQueueItem.class);
+=====================================================================
+Found a 10 line (74 tokens) duplication in the following files:
+Starting at line 375 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/common/unittesthelper/util/UnitTestCreateDomainObjectUtils.java
+Starting at line 390 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/common/unittesthelper/util/UnitTestCreateDomainObjectUtils.java
+
+ public static RelatedPublication buildRelatedPublication() {
+
+ List dataPackageIds = new ArrayList<>();
+ dataPackageIds.add(UnitTestCreateValidIds.buildDataPackageId("testproject"));
+
+ return RelatedPublication.builder().doi("A DOI")
+ .id(UnitTestCreateValidIds.buildRelatedPublicationId("HurzId123"))
+ .publicationAbstract("A publication Abstract").sourceLink("http://www.hurzexample.de/")
+ .sourceReference("A Source Reference").title("A Title of a Related Publication")
+ .dataPackageIds(dataPackageIds).authors("Author").year(2017)
+=====================================================================
+Found a 18 line (74 tokens) duplication in the following files:
+Starting at line 55 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageAttachmentShadowCopyServiceTest.java
+Starting at line 55 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentShadowCopyServiceTest.java
+Starting at line 51 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/service/SurveyAttachmentShadowCopyServiceTest.java
+
+ private DataPackageAttachmentShadowCopyService shadowCopyService;
+
+ private DataAcquisitionProject dataAcquisitionProject;
+
+ private Release release;
+
+ @Before
+ public void setup() {
+ release = new Release("1.0.0", LocalDateTime.now(), null, false);
+
+ dataAcquisitionProject = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProject.setId(PROJECT_ID);
+ dataAcquisitionProject.setRelease(release);
+ }
+
+ @After
+ public void teardown() {
+ Query query = new Query(GridFsCriteria.whereFilename().regex("^/data-packages"));
+=====================================================================
+Found a 10 line (74 tokens) duplication in the following files:
+Starting at line 90 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+Starting at line 333 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+
+ // create the survey with the given id
+ mockMvc.perform(put(API_SURVEYS_URI + "/" + survey.getId())
+ .content(TestUtil.convertObjectToJsonBytes(survey)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ // read the survey under the new url
+ mockMvc.perform(get(API_SURVEYS_URI + "/" + survey.getId()))
+ .andExpect(status().isOk());
+=====================================================================
+Found a 9 line (74 tokens) duplication in the following files:
+Starting at line 21 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/domain/QDataPackage.java
+Starting at line 23 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/domain/QDataSet.java
+Starting at line 21 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/domain/QInstrument.java
+Starting at line 20 of /home/reitmann/data/metadatamanagement/target/generated-sources/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/domain/QSurvey.java
+
+ public static final QDataPackage dataPackage = new QDataPackage("dataPackage");
+
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject _super = new eu.dzhw.fdz.metadatamanagement.common.domain.QAbstractShadowableRdcDomainObject(this);
+
+ // custom
+ public final eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString annotations = new eu.dzhw.fdz.metadatamanagement.common.domain.QI18nString(forProperty("annotations"));
+
+ //inherited
+ public final StringPath createdBy = _super.createdBy;
+=====================================================================
+Found a 14 line (73 tokens) duplication in the following files:
+Starting at line 186 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/service/ConceptManagementService.java
+Starting at line 210 of /home/reitmann/data/metadatamanagement/src/main/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/service/ConceptManagementService.java
+
+ conceptIds.addAll(questionRepository.findSubDocumentsByIdIn(questionIds).stream()
+ .map(question -> question.getConceptIds() != null ? question.getConceptIds()
+ : new ArrayList())
+ .flatMap(List::stream).collect(Collectors.toSet()));
+ return conceptRepository.streamIdsByIdIn(conceptIds);
+ }, ElasticsearchType.concepts);
+ }
+
+ /**
+ * Enqueue update of concept search documents when the variable changed.
+ *
+ * @param variable the updated, created or deleted variable.
+ */
+ @HandleAfterCreate
+=====================================================================
+Found a 13 line (73 tokens) duplication in the following files:
+Starting at line 257 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+Starting at line 272 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageResourceControllerTest.java
+
+ dataPackage.setId(dataPackage.getId() + "-1.0.0");
+
+ mockMvc
+ .perform(put(API_DATAPACKAGE_URI + "/" + dataPackage.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataPackage))
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isBadRequest()).andExpect(jsonPath("$.errors[0].message",
+ containsString("global.error.shadow-save-not-allowed")));
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER)
+ public void testUpdateShadowCopyDataPackage() throws Exception {
+=====================================================================
+Found a 16 line (73 tokens) duplication in the following files:
+Starting at line 57 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/service/DataPackageAttachmentShadowCopyServiceTest.java
+Starting at line 57 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/service/DataSetAttachmentShadowCopyServiceTest.java
+Starting at line 57 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/service/InstrumentAttachmentShadowCopyServiceTest.java
+Starting at line 58 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/service/QuestionImageShadowCopyServiceTest.java
+Starting at line 53 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/service/SurveyAttachmentShadowCopyServiceTest.java
+
+ private DataAcquisitionProject dataAcquisitionProject;
+
+ private Release release;
+
+ @Before
+ public void setup() {
+ release = new Release("1.0.0", LocalDateTime.now(), null, false);
+
+ dataAcquisitionProject = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProject.setId(PROJECT_ID);
+ dataAcquisitionProject.setRelease(release);
+ }
+
+ @After
+ public void teardown() {
+ Query query = new Query(GridFsCriteria.whereFilename().regex("^/data-packages"));
+=====================================================================
+Found a 6 line (73 tokens) duplication in the following files:
+Starting at line 110 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+Starting at line 144 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+Starting at line 108 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 139 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/questionmanagement/rest/QuestionResourceControllerTest.java
+Starting at line 124 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+Starting at line 155 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+
+ mockMvc.perform(get(API_DATASETS_URI + "/" + dataSet.getId()))
+ .andExpect(status().isOk())
+ .andExpect(jsonPath("$.createdDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.lastModifiedDate", not(isEmptyOrNullString())))
+ .andExpect(jsonPath("$.createdBy", is("user")))
+ .andExpect(jsonPath("$.lastModifiedBy", is("user")));
+=====================================================================
+Found a 11 line (73 tokens) duplication in the following files:
+Starting at line 253 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+Starting at line 363 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetResourceControllerTest.java
+
+ Survey survey = UnitTestCreateDomainObjectUtils.buildSurvey(project.getId());
+
+ DataSet dataSet = UnitTestCreateDomainObjectUtils.buildDataSet(project.getId(), survey.getId(), 1);
+
+ // create the DataSet with the given id
+ mockMvc.perform(put(API_DATASETS_URI + "/" + dataSet.getId())
+ .content(TestUtil.convertObjectToJsonBytes(dataSet)).contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isCreated());
+
+ // delete the DataSet
+ mockMvc.perform(delete(API_DATASETS_URI + "/" + dataSet.getId()))
+=====================================================================
+Found a 12 line (72 tokens) duplication in the following files:
+Starting at line 130 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 162 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+
+ + "/attachments/" + attachment.getOriginalFilename()))
+ .andExpect(status().is2xxSuccessful());
+
+ // ensure the uploaded file does not exist anymore
+ mockMvc
+ .perform(get("/api/concepts/" + conceptAttachmentMetadata.getConceptId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(0)));
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER, username = "test")
+ public void testDeleteAllAttachments() throws Exception {
+=====================================================================
+Found a 9 line (72 tokens) duplication in the following files:
+Starting at line 135 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptAttachmentResourceTest.java
+Starting at line 146 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 146 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 137 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+
+ .perform(get("/api/concepts/" + conceptAttachmentMetadata.getConceptId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(0)));
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER, username = "test")
+ public void testDeleteAllAttachments() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+=====================================================================
+Found a 11 line (72 tokens) duplication in the following files:
+Starting at line 90 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptResourceControllerTest.java
+Starting at line 104 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/conceptmanagement/rest/ConceptResourceControllerTest.java
+
+ mockMvc.perform(put(API_CONCEPT_URI + "/" + concept.getId())
+ .content(TestUtil.convertObjectToJsonBytes(concept))
+ .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isCreated());
+
+ // read the concept under the new url
+ mockMvc.perform(get(API_CONCEPT_URI + "/" + concept.getId())).andExpect(status().isOk());
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER)
+ public void testCreateConceptWithPost() throws IOException, Exception {
+=====================================================================
+Found a 12 line (72 tokens) duplication in the following files:
+Starting at line 141 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 174 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+
+ + "/attachments/" + attachment.getOriginalFilename()))
+ .andExpect(status().is2xxSuccessful());
+
+ // ensure the uploaded file does not exist anymore
+ mockMvc.perform(get(
+ "/api/data-packages/" + dataPackageAttachmentMetadata.getDataPackageId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(0)));
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER, username = "test")
+ public void testDeleteAllAttachments() throws Exception {
+=====================================================================
+Found a 9 line (72 tokens) duplication in the following files:
+Starting at line 179 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 179 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+
+ "/api/data-packages/" + dataPackageAttachmentMetadata.getDataPackageId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(0)));
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER, username = "test")
+ public void testUpdateAttachment() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+=====================================================================
+Found a 11 line (72 tokens) duplication in the following files:
+Starting at line 336 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datapackagemanagement/rest/DataPackageAttachmentResourceTest.java
+Starting at line 315 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+
+ put("/api/data-packages/" + dataPackageId + "/attachments/" + metadata.getFileName())
+ .content(TestUtil.convertObjectToJsonBytes(metadata))
+ .contentType(MediaType.APPLICATION_JSON))
+ .andExpect(status().isBadRequest()).andExpect(jsonPath("$.errors[0].message",
+ containsString("global.error.shadow-save-not-allowed")));
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER)
+ public void testDeleteAllAttachmentsOfShadowCopyDataPackage() throws Exception {
+ String dataPackageId = "stu-issue1991-1.0.0";
+=====================================================================
+Found a 12 line (72 tokens) duplication in the following files:
+Starting at line 141 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+Starting at line 174 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/datasetmanagement/rest/DataSetAttachmentResourceTest.java
+
+ + "/attachments/" + attachment.getOriginalFilename()))
+ .andExpect(status().is2xxSuccessful());
+
+ // ensure the uploaded file does not exist anymore
+ mockMvc
+ .perform(get("/api/data-sets/" + dataSetAttachmentMetadata.getDataSetId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(0)));
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER, username = "test")
+ public void testDeleteAllAttachments() throws Exception {
+=====================================================================
+Found a 9 line (72 tokens) duplication in the following files:
+Starting at line 127 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/instrumentmanagement/rest/InstrumentAttachmentResourceTest.java
+Starting at line 164 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+
+ "/api/instruments/" + instrumentAttachmentMetadata.getInstrumentId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(0)));
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER, username = "test")
+ public void testUpdateAttachmentMetadata() throws Exception {
+ MockMultipartFile attachment =
+ new MockMultipartFile("file", "filename.txt", "text/plain", "some text".getBytes());
+=====================================================================
+Found a 8 line (72 tokens) duplication in the following files:
+Starting at line 158 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectVersionsResourceTest.java
+Starting at line 168 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectVersionsResourceTest.java
+Starting at line 179 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/projectmanagement/rest/DataAcquisitionProjectVersionsResourceTest.java
+
+ project.setRelease(UnitTestCreateDomainObjectUtils.buildRelease());
+ this.mockMvc.perform(put(API_DATA_ACQUISITION_PROJECTS_URI + "/" + project.getId())
+ .contentType(MediaType.APPLICATION_JSON)
+ .content(TestUtil.convertObjectToJsonBytes(project))).andExpect(status().isNoContent());
+
+ // Assert that the last version is 1.0.0
+ lastRelease = this.versionsService.findLastRelease(project.getId());
+ assertThat(lastRelease.getVersion(), is("1.0.0"));
+=====================================================================
+Found a 11 line (72 tokens) duplication in the following files:
+Starting at line 133 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+Starting at line 160 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyAttachmentResourceTest.java
+
+ + "/attachments/" + attachment.getOriginalFilename()))
+ .andExpect(status().is2xxSuccessful());
+
+ // ensure the uploaded file does not exist anymore
+ mockMvc.perform(get("/api/surveys/" + surveyAttachmentMetadata.getSurveyId() + "/attachments"))
+ .andExpect(status().isOk()).andExpect(jsonPath("$.length()", is(0)));
+ }
+
+ @Test
+ @WithMockUser(authorities = AuthoritiesConstants.PUBLISHER, username = "test")
+ public void testDeleteAllAttachments() throws Exception {
+=====================================================================
+Found a 10 line (72 tokens) duplication in the following files:
+Starting at line 163 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+Starting at line 201 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/surveymanagement/rest/SurveyResourceControllerTest.java
+
+ rdcProjectRepository.save(project);
+
+ Survey survey = Survey.builder().id("testId")
+ .dataAcquisitionProjectId(project.getId())
+ .title(I18nString.builder().de("titel")
+ .en("title")
+ .build())
+ .fieldPeriod(Period.builder().start(LocalDate.now())
+ .end(LocalDate.now()
+ .minusDays(1))
+=====================================================================
+Found a 11 line (72 tokens) duplication in the following files:
+Starting at line 234 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+Starting at line 260 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+Starting at line 288 of /home/reitmann/data/metadatamanagement/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceControllerTest.java
+
+ public void testCreateDateVariableWithOrdinalScaleLevel() throws Exception {
+ DataAcquisitionProject project = UnitTestCreateDomainObjectUtils.buildDataAcquisitionProject();
+ dataAcquisitionProjectRepository.save(project);
+
+ List