diff options
author | Thomas <> | 2022-07-01 14:48:10 +0200 |
---|---|---|
committer | Thomas <> | 2022-07-01 14:48:10 +0200 |
commit | 8bb5373a38f43d83c041ec0739459e38eb7cc3e2 (patch) | |
tree | dbcc984a7e37db582ca590494441a48e7d793f38 /modules/authmodule-eIDAS-v2/src/test/java | |
parent | 847e3f5b52a7adc6baa463258087e562049ee89b (diff) | |
download | National_eIDAS_Gateway-8bb5373a38f43d83c041ec0739459e38eb7cc3e2.tar.gz National_eIDAS_Gateway-8bb5373a38f43d83c041ec0739459e38eb7cc3e2.tar.bz2 National_eIDAS_Gateway-8bb5373a38f43d83c041ec0739459e38eb7cc3e2.zip |
feat(matching): optimize order of address search results
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/test/java')
-rw-r--r-- | modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/utils/AddressSearchResultTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/utils/AddressSearchResultTest.java b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/utils/AddressSearchResultTest.java new file mode 100644 index 00000000..89692ab7 --- /dev/null +++ b/modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/utils/AddressSearchResultTest.java @@ -0,0 +1,55 @@ +package at.asitplus.eidas.specific.modules.auth.eidas.v2.test.utils; + +import static org.junit.Assert.assertArrayEquals; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.mockito.internal.util.collections.Sets; + +import at.asitplus.eidas.specific.modules.auth.eidas.v2.controller.AdresssucheController.AdresssucheOutput; + +@RunWith(BlockJUnit4ClassRunner.class) +public class AddressSearchResultTest { + + @Test + public void checkNumbers() { + + Set<AdresssucheOutput> result = Sets.newSet( + buildRandom("2"), + buildRandom("3"), + buildRandom("1"), + buildRandom("10"), + buildRandom("10-12"), + buildRandom("15") + ); + + final List<String> sorted = result.stream().sorted().limit(30) + .map(el -> el.getNumber()) + .collect(Collectors.toList()); + + + assertArrayEquals("wrong order", + new Object[]{"1", "2", "3", "10", "15", "10-12"}, + sorted.toArray()); + + + + + } + + private AdresssucheOutput buildRandom(String number) { + return AdresssucheOutput.builder() + .municipality("aaaaaaaa") + .postleitzahl("8080") + .street("bbbbb") + .number(number) + .village("cccccc") + .build(); + } + +} |