|
5 | 5 | import net.contargo.iris.address.AddressList; |
6 | 6 | import net.contargo.iris.address.nominatim.service.AddressService; |
7 | 7 | import net.contargo.iris.address.staticsearch.StaticAddress; |
| 8 | +import net.contargo.iris.address.staticsearch.service.StaticAddressNotFoundException; |
8 | 9 | import net.contargo.iris.address.staticsearch.service.StaticAddressService; |
9 | 10 | import net.contargo.iris.normalizer.NormalizerService; |
10 | 11 |
|
|
38 | 39 | import static org.mockito.Matchers.any; |
39 | 40 | import static org.mockito.Matchers.eq; |
40 | 41 |
|
| 42 | +import static org.mockito.Mockito.doThrow; |
41 | 43 | import static org.mockito.Mockito.verify; |
42 | 44 | import static org.mockito.Mockito.verifyZeroInteractions; |
43 | 45 | import static org.mockito.Mockito.when; |
44 | 46 |
|
45 | 47 | import static java.util.Arrays.asList; |
| 48 | +import static java.util.Collections.emptyList; |
46 | 49 | import static java.util.Collections.singletonList; |
47 | 50 |
|
48 | 51 |
|
@@ -465,4 +468,29 @@ public void getAddressesByQueryWithHashkey() { |
465 | 468 |
|
466 | 469 | verifyZeroInteractions(addressServiceMock); |
467 | 470 | } |
| 471 | + |
| 472 | + |
| 473 | + @Test |
| 474 | + public void getAddressesByQueryWithHashkeyNotFound() { |
| 475 | + |
| 476 | + doThrow(StaticAddressNotFoundException.class).when(staticAddressServiceMock).findByHashKey("76135"); |
| 477 | + |
| 478 | + Address address = new Address(); |
| 479 | + address.setDisplayName("Gartenstr. 67, Karlsruhe (Südweststadt)"); |
| 480 | + address.getAddress().put("city", "Karlsruhe"); |
| 481 | + address.getAddress().put("postcode", "76135"); |
| 482 | + address.getAddress().put("country_code", "de"); |
| 483 | + address.getAddress().put("street", "Gartenstr."); |
| 484 | + |
| 485 | + when(addressServiceMock.getAddressesByQuery("76135")).thenReturn(singletonList(address)); |
| 486 | + |
| 487 | + when(staticAddressServiceMock.findAddresses("76135", "Karlsruhe", "de")).thenReturn(new AddressList("", |
| 488 | + emptyList())); |
| 489 | + |
| 490 | + List<Address> addresses = sut.getAddressesByQuery("76135"); |
| 491 | + |
| 492 | + assertThat(addresses, hasSize(1)); |
| 493 | + assertThat(addresses.get(0).getCity(), is("Karlsruhe")); |
| 494 | + assertThat(addresses.get(0).getPostcode(), is("76135")); |
| 495 | + } |
468 | 496 | } |
0 commit comments