-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Add template autoselection tests
- Loading branch information
1 parent
f070647
commit 5a3b6c7
Showing
1 changed file
with
82 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
src/test/java/at/ac/tuwien/damap/conversion/TemplateSelectorServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package at.ac.tuwien.damap.conversion; | ||
|
||
import at.ac.tuwien.damap.TestSetup; | ||
import at.ac.tuwien.damap.enums.ETemplateType; | ||
import at.ac.tuwien.damap.rest.dmp.domain.DmpDO; | ||
import at.ac.tuwien.damap.rest.dmp.domain.FundingDO; | ||
import at.ac.tuwien.damap.rest.dmp.domain.ProjectDO; | ||
import at.ac.tuwien.damap.util.MockDmpService; | ||
import at.ac.tuwien.damap.util.TestDOFactory; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.security.TestSecurity; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.inject.Inject; | ||
|
||
@QuarkusTest | ||
class TemplateSelectorServiceImplTest extends TestSetup { | ||
|
||
@Inject | ||
TestDOFactory testDOFactory; | ||
|
||
@Inject | ||
MockDmpService dmpService; | ||
|
||
@Inject | ||
TemplateSelectorServiceImpl templateSelectorService; | ||
|
||
@Test | ||
@TestSecurity(authorizationEnabled = false) | ||
void givenDmpHasUnknownFunding_whenTemplateIsSelected_thenShouldReturnScienceEurope() { | ||
DmpDO testDMP = testDOFactory.createDmp(this.toString(), true); | ||
|
||
ProjectDO project = testDMP.getProject(); | ||
project.setUniversityId("123456UnknwonFunder"); | ||
project.setDescription("Test unknown funder."); | ||
FundingDO fundingDO = project.getFunding(); | ||
fundingDO.getFunderId().setIdentifier("501100004955"); | ||
project.setFunding(fundingDO); | ||
|
||
testDMP.setProject(project); | ||
DmpDO updatedDMP = dmpService.update(testDMP); | ||
|
||
Assertions.assertEquals(ETemplateType.SCIENCE_EUROPE, templateSelectorService.selectTemplate(updatedDMP)); | ||
} | ||
|
||
@Test | ||
@TestSecurity(authorizationEnabled = false) | ||
void givenDmpHasFWFFunding_whenTemplateIsSelected_thenShouldReturnFWF() { | ||
DmpDO testDMP = testDOFactory.createDmp(this.toString(), true); | ||
|
||
ProjectDO project = testDMP.getProject(); | ||
project.setUniversityId("123456FWFFunder"); | ||
project.setDescription("Test FWF funder."); | ||
FundingDO fundingDO = project.getFunding(); | ||
fundingDO.getFunderId().setIdentifier("501100002428"); | ||
project.setFunding(fundingDO); | ||
|
||
testDMP.setProject(project); | ||
DmpDO updatedDMP = dmpService.update(testDMP); | ||
|
||
Assertions.assertEquals(ETemplateType.FWF, templateSelectorService.selectTemplate(updatedDMP)); | ||
} | ||
|
||
@Test | ||
@TestSecurity(authorizationEnabled = false) | ||
void givenDmpHasUnknownFunding_whenTemplateIsSelected_thenShouldReturnHorizonEurope() { | ||
DmpDO testDMP = testDOFactory.createDmp(this.toString(), true); | ||
|
||
ProjectDO project = testDMP.getProject(); | ||
project.setUniversityId("123456HEFunder"); | ||
project.setDescription("Test HE funder."); | ||
FundingDO fundingDO = project.getFunding(); | ||
fundingDO.getFunderId().setIdentifier("501100000780"); | ||
project.setFunding(fundingDO); | ||
|
||
testDMP.setProject(project); | ||
DmpDO updatedDMP = dmpService.update(testDMP); | ||
|
||
Assertions.assertEquals(ETemplateType.HORIZON_EUROPE, templateSelectorService.selectTemplate(updatedDMP)); | ||
} | ||
} |