-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
...va/de/bund/digitalservice/ris/norms/adapter/output/database/mapper/ArticleMapperTest.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,73 @@ | ||
package de.bund.digitalservice.ris.norms.adapter.output.database.mapper; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import de.bund.digitalservice.ris.norms.adapter.output.database.dto.ArticleDto; | ||
import de.bund.digitalservice.ris.norms.adapter.output.database.dto.TargetLawDto; | ||
import de.bund.digitalservice.ris.norms.domain.entity.Article; | ||
import de.bund.digitalservice.ris.norms.domain.entity.TargetLaw; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ArticleMapperTest { | ||
|
||
@Test | ||
void testMapToDomain() { | ||
// Given | ||
final TargetLawDto targetLawDto = | ||
TargetLawDto.builder().eli("123").title("Test Law").xml("<xml>Test XML</xml>").build(); | ||
|
||
final ArticleDto articleDto = | ||
ArticleDto.builder() | ||
.enumeration("1") | ||
.title("Test Article") | ||
.eid("article-1") | ||
.targetLawDto(targetLawDto) | ||
.build(); | ||
|
||
// When | ||
final Article article = ArticleMapper.mapToDomain(articleDto); | ||
|
||
// Then | ||
assertNotNull(article); | ||
assertEquals(articleDto.getEnumeration(), article.getEnumeration()); | ||
assertEquals(articleDto.getTitle(), article.getTitle()); | ||
assertEquals(articleDto.getEid(), article.getEid()); | ||
assertNotNull(article.getTargetLaw()); | ||
assertEquals(targetLawDto.getEli(), article.getTargetLaw().getEli()); | ||
assertEquals(targetLawDto.getTitle(), article.getTargetLaw().getTitle()); | ||
assertEquals(targetLawDto.getXml(), article.getTargetLaw().getXml()); | ||
} | ||
|
||
@Test | ||
void testMapToDto() { | ||
// Given | ||
final TargetLaw targetLaw = | ||
TargetLaw.builder() | ||
.eli("456") | ||
.title("Another Test Law") | ||
.xml("<xml>Another Test XML</xml>") | ||
.build(); | ||
|
||
final Article article = | ||
Article.builder() | ||
.enumeration("2") | ||
.title("Another Test Article") | ||
.eid("article-2") | ||
.targetLaw(targetLaw) | ||
.build(); | ||
|
||
// When | ||
final ArticleDto articleDto = ArticleMapper.mapToDto(article); | ||
|
||
// Then | ||
assertNotNull(articleDto); | ||
assertEquals(article.getEnumeration(), articleDto.getEnumeration()); | ||
assertEquals(article.getTitle(), articleDto.getTitle()); | ||
assertEquals(article.getEid(), articleDto.getEid()); | ||
assertNotNull(articleDto.getTargetLawDto()); | ||
assertEquals(targetLaw.getEli(), articleDto.getTargetLawDto().getEli()); | ||
assertEquals(targetLaw.getTitle(), articleDto.getTargetLawDto().getTitle()); | ||
assertEquals(targetLaw.getXml(), articleDto.getTargetLawDto().getXml()); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
.../de/bund/digitalservice/ris/norms/adapter/output/database/mapper/TargetLawMapperTest.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,47 @@ | ||
package de.bund.digitalservice.ris.norms.adapter.output.database.mapper; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import de.bund.digitalservice.ris.norms.adapter.output.database.dto.TargetLawDto; | ||
import de.bund.digitalservice.ris.norms.domain.entity.TargetLaw; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class TargetLawMapperTest { | ||
|
||
@Test | ||
void testMapToDomain() { | ||
// Given | ||
final TargetLawDto targetLawDto = | ||
TargetLawDto.builder().eli("123").title("Test Law").xml("<xml>Test XML</xml>").build(); | ||
|
||
// When | ||
final TargetLaw targetLaw = TargetLawMapper.mapToDomain(targetLawDto); | ||
|
||
// Then | ||
assertNotNull(targetLaw); | ||
assertEquals(targetLawDto.getEli(), targetLaw.getEli()); | ||
assertEquals(targetLawDto.getTitle(), targetLaw.getTitle()); | ||
assertEquals(targetLawDto.getXml(), targetLaw.getXml()); | ||
} | ||
|
||
@Test | ||
void testMapToDto() { | ||
// Given | ||
final TargetLaw targetLaw = | ||
TargetLaw.builder() | ||
.eli("456") | ||
.title("Another Test Law") | ||
.xml("<xml>Another Test XML</xml>") | ||
.build(); | ||
|
||
// When | ||
final TargetLawDto targetLawDto = TargetLawMapper.mapToDto(targetLaw); | ||
|
||
// Then | ||
assertNotNull(targetLawDto); | ||
assertEquals(targetLaw.getEli(), targetLawDto.getEli()); | ||
assertEquals(targetLaw.getTitle(), targetLawDto.getTitle()); | ||
assertEquals(targetLaw.getXml(), targetLawDto.getXml()); | ||
} | ||
} |