2984 PO 6) Remove plagiarism analysis when rejecting the final thesis.
This commit is contained in:
parent
b5a3e59a53
commit
85324918f6
core/src
main/java/se/su/dsv/scipro/finalthesis
test
@ -119,7 +119,9 @@ public class FinalThesisServiceImpl extends AbstractServiceImpl<FinalThesis, Lon
|
||||
FileReference textMatchingDocument = finalThesis.getTextMatchingDocument();
|
||||
finalThesis.setTextMatchingDocument(null);
|
||||
finalThesis.setTextMatchingAnalysis(null);
|
||||
fileService.delete(textMatchingDocument);
|
||||
if (textMatchingDocument != null) {
|
||||
fileService.delete(textMatchingDocument);
|
||||
}
|
||||
save(finalThesis);
|
||||
}
|
||||
|
||||
@ -150,7 +152,8 @@ public class FinalThesisServiceImpl extends AbstractServiceImpl<FinalThesis, Lon
|
||||
@Override
|
||||
@Transactional
|
||||
public void reject(Project project) {
|
||||
setStatus(project, FinalThesis.Status.REJECTED);
|
||||
FinalThesis finalThesis = setStatus(project, FinalThesis.Status.REJECTED);
|
||||
removePlagiarismAnalysis(finalThesis);
|
||||
eventBus.post(new FinalThesisRejectedEvent(project));
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@ import org.hamcrest.TypeSafeMatcher;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import se.su.dsv.scipro.file.FileReference;
|
||||
import se.su.dsv.scipro.file.FileService;
|
||||
import se.su.dsv.scipro.file.ProjectFileUpload;
|
||||
import se.su.dsv.scipro.notifications.dataobject.NotificationSource;
|
||||
import se.su.dsv.scipro.project.Project;
|
||||
@ -13,9 +15,11 @@ import se.su.dsv.scipro.system.DegreeType;
|
||||
import se.su.dsv.scipro.system.ProjectType;
|
||||
import se.su.dsv.scipro.system.User;
|
||||
import se.su.dsv.scipro.test.IntegrationTest;
|
||||
import se.su.dsv.scipro.test.StreamingUpload;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.everyItem;
|
||||
@ -30,6 +34,8 @@ public class FinalThesisServiceImplTest extends IntegrationTest {
|
||||
|
||||
@Inject
|
||||
private FinalThesisServiceImpl finalThesisService;
|
||||
@Inject
|
||||
private FileService fileService;
|
||||
|
||||
private User uploader;
|
||||
private Project project;
|
||||
@ -112,6 +118,22 @@ public class FinalThesisServiceImplTest extends IntegrationTest {
|
||||
assertNotNull(finalThesis.getDateRejected());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removes_plagiarism_analysis_when_rejecting_thesis() {
|
||||
InputStream data = FinalThesisServiceImplTest.class.getResourceAsStream("/text_matching_analysis.txt");
|
||||
StreamingUpload fileUpload = new StreamingUpload("plagiarism_analysis.txt", "text/plain", uploader, 24, data);
|
||||
FileReference fileReference = fileService.storeFile(fileUpload);
|
||||
|
||||
FinalThesis finalThesis = uploadThesis();
|
||||
finalThesis.setTextMatchingAnalysis("analysis");
|
||||
finalThesis.setTextMatchingDocument(fileReference);
|
||||
|
||||
finalThesisService.reject(project);
|
||||
|
||||
assertNull(finalThesis.getTextMatchingAnalysis());
|
||||
assertNull(finalThesis.getTextMatchingDocument());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void uploading_is_allowed_if_no_final_thesis_exists() {
|
||||
assertTrue(finalThesisService.isUploadAllowed(project));
|
||||
|
1
core/src/test/resources/text_matching_analysis.txt
Normal file
1
core/src/test/resources/text_matching_analysis.txt
Normal file
@ -0,0 +1 @@
|
||||
No text matching found.
|
Loading…
x
Reference in New Issue
Block a user