Add test data
This commit is contained in:
parent
21390b5f8a
commit
bce2e27f5d
test-data/src/main/java/se/su/dsv/scipro/testdata
@ -1,6 +1,9 @@
|
|||||||
package se.su.dsv.scipro.testdata;
|
package se.su.dsv.scipro.testdata;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import se.su.dsv.scipro.match.Keyword;
|
||||||
import se.su.dsv.scipro.system.ProjectType;
|
import se.su.dsv.scipro.system.ProjectType;
|
||||||
|
import se.su.dsv.scipro.system.ResearchArea;
|
||||||
|
|
||||||
/// All the base test data that can be re-used in different test cases.
|
/// All the base test data that can be re-used in different test cases.
|
||||||
///
|
///
|
||||||
@ -16,4 +19,11 @@ public interface BaseData {
|
|||||||
ProjectType bachelor();
|
ProjectType bachelor();
|
||||||
ProjectType magister();
|
ProjectType magister();
|
||||||
ProjectType master();
|
ProjectType master();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return generic research area with some keywords attached to it
|
||||||
|
*/
|
||||||
|
ResearchAreaAndKeywords researchArea();
|
||||||
|
|
||||||
|
record ResearchAreaAndKeywords(ResearchArea researchArea, List<Keyword> keywords) {}
|
||||||
}
|
}
|
||||||
|
@ -2193,6 +2193,11 @@ public class DataInitializer implements Lifecycle, BaseData, Factory {
|
|||||||
return createEmployee(firstName);
|
return createEmployee(firstName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResearchAreaAndKeywords researchArea() {
|
||||||
|
return new ResearchAreaAndKeywords(researchArea1, List.of(keyword1, keyword2));
|
||||||
|
}
|
||||||
|
|
||||||
private static final class SimpleTextFile implements FileUpload {
|
private static final class SimpleTextFile implements FileUpload {
|
||||||
|
|
||||||
private final User uploader;
|
private final User uploader;
|
||||||
|
68
test-data/src/main/java/se/su/dsv/scipro/testdata/populators/PartnerTypeException.java
vendored
Normal file
68
test-data/src/main/java/se/su/dsv/scipro/testdata/populators/PartnerTypeException.java
vendored
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package se.su.dsv.scipro.testdata.populators;
|
||||||
|
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Set;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import se.su.dsv.scipro.match.ApplicationPeriod;
|
||||||
|
import se.su.dsv.scipro.match.ApplicationPeriodService;
|
||||||
|
import se.su.dsv.scipro.match.Idea;
|
||||||
|
import se.su.dsv.scipro.match.IdeaService;
|
||||||
|
import se.su.dsv.scipro.match.Target;
|
||||||
|
import se.su.dsv.scipro.match.TargetService;
|
||||||
|
import se.su.dsv.scipro.system.User;
|
||||||
|
import se.su.dsv.scipro.testdata.BaseData;
|
||||||
|
import se.su.dsv.scipro.testdata.Factory;
|
||||||
|
import se.su.dsv.scipro.testdata.TestDataPopulator;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class PartnerTypeException implements TestDataPopulator {
|
||||||
|
|
||||||
|
private final ApplicationPeriodService applicationPeriodService;
|
||||||
|
private final IdeaService ideaService;
|
||||||
|
private final TargetService targetService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public PartnerTypeException(
|
||||||
|
ApplicationPeriodService applicationPeriodService,
|
||||||
|
IdeaService ideaService,
|
||||||
|
TargetService targetService
|
||||||
|
) {
|
||||||
|
this.applicationPeriodService = applicationPeriodService;
|
||||||
|
this.ideaService = ideaService;
|
||||||
|
this.targetService = targetService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(BaseData baseData, Factory factory) {
|
||||||
|
factory.createAuthor("Oskar");
|
||||||
|
|
||||||
|
User johan = factory.createAuthor("Johan");
|
||||||
|
johan.setDegreeType(baseData.master().getDegreeType());
|
||||||
|
|
||||||
|
User supervisor = factory.createSupervisor("Elsa");
|
||||||
|
|
||||||
|
ApplicationPeriod applicationPeriod = new ApplicationPeriod("Supervisor ideas");
|
||||||
|
applicationPeriod.setStartDate(LocalDate.now());
|
||||||
|
applicationPeriod.setEndDate(LocalDate.now().plusDays(14));
|
||||||
|
applicationPeriod.setCourseStartDateTime(LocalDateTime.now().plusDays(15));
|
||||||
|
applicationPeriod.setProjectTypes(Set.of(baseData.bachelor()));
|
||||||
|
applicationPeriodService.save(applicationPeriod);
|
||||||
|
|
||||||
|
Target target = targetService.findOne(applicationPeriod, supervisor, baseData.bachelor());
|
||||||
|
target.setTarget(10);
|
||||||
|
targetService.save(target);
|
||||||
|
|
||||||
|
Idea idea = new Idea();
|
||||||
|
idea.setPublished(true);
|
||||||
|
idea.setTitle("The next gen AI 2.0 turbo edition");
|
||||||
|
idea.setPrerequisites("Hacker experience");
|
||||||
|
idea.setDescription("Better than all the rest");
|
||||||
|
idea.setProjectType(baseData.bachelor());
|
||||||
|
idea.setApplicationPeriod(applicationPeriod);
|
||||||
|
idea.setResearchArea(baseData.researchArea().researchArea());
|
||||||
|
|
||||||
|
ideaService.saveSupervisorIdea(idea, supervisor, baseData.researchArea().keywords(), true);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user