[APC at the result level] added other test

This commit is contained in:
Miriam Baglioni 2022-02-04 13:18:46 +01:00
parent 2895988f2b
commit 91af2dade8
2 changed files with 34 additions and 0 deletions

View File

@ -162,7 +162,11 @@ class MergeTest {
p1.mergeFrom(p2);
assertEquals("1721.47", p1.getProcessingchargeamount().getValue());
assertEquals("EUR", p1.getProcessingchargecurrency().getValue());
assertEquals(2 , p1.getInstance().size());
p1.getInstance().stream().forEach(i -> assertTrue(i.getProcessingchargeamount() != null));
p1.getInstance().stream().forEach(i -> assertTrue(i.getProcessingchargecurrency() != null));
@ -173,7 +177,35 @@ class MergeTest {
p1.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency().getValue().equals("USD"));
System.out.println(new ObjectMapper().writeValueAsString(p1));
}
@Test
void testAPCMerge2() throws Exception {
List<Result> publications = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/publication_apc2.json", Publication.class);
System.out.println(publications.size());
publications.forEach(p -> assertEquals(1, p.getInstance().size()));
assertTrue(publications.get(0).getProcessingchargeamount() != null );
assertTrue(publications.get(0).getProcessingchargecurrency() != null );
assertTrue(publications.get(1).getProcessingchargeamount() == null );
Result p1 = publications.get(1);
Result p2 = publications.get(0);
p1.mergeFrom(p2);
assertEquals("1721.47", p1.getProcessingchargeamount().getValue());
assertEquals("EUR", p1.getProcessingchargecurrency().getValue());
assertEquals(2 , p1.getInstance().size());
p1.getInstance().stream().anyMatch(i -> i.getProcessingchargeamount() != null);
p1.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency() != null);
assertEquals("1721.47", p1.getInstance().stream().filter(i -> i.getProcessingchargeamount() != null)
.collect(Collectors.toList()).get(0).getProcessingchargeamount().getValue());
assertEquals("EUR", p1.getInstance().stream().filter(i -> i.getProcessingchargeamount() != null)
.collect(Collectors.toList()).get(0).getProcessingchargecurrency().getValue());
System.out.println(new ObjectMapper().writeValueAsString(p1));
}
/**
* Test enrichment function.

File diff suppressed because one or more lines are too long