From dddfc053490ac793930e4cd799bc929dad2e297f Mon Sep 17 00:00:00 2001 From: Sallo Szrajbman Date: Mon, 8 Mar 2021 21:15:42 +0000 Subject: [PATCH] BAEL-4362 - Generate WSDL Stubs with Maven Removing blank lines Fixing test names to BDD-style --- .../soap/ws/client/CountryServiceClient.java | 3 +-- .../soap/ws/client/CountryServiceClientUnitTest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/maven-modules/maven-plugins/jaxws/src/main/java/com/baeldung/soap/ws/client/CountryServiceClient.java b/maven-modules/maven-plugins/jaxws/src/main/java/com/baeldung/soap/ws/client/CountryServiceClient.java index 5e6b4b135e..d6175890f9 100644 --- a/maven-modules/maven-plugins/jaxws/src/main/java/com/baeldung/soap/ws/client/CountryServiceClient.java +++ b/maven-modules/maven-plugins/jaxws/src/main/java/com/baeldung/soap/ws/client/CountryServiceClient.java @@ -9,6 +9,7 @@ public class CountryServiceClient { public CountryServiceClient(CountryService countryService) { this.countryService = countryService; } + public String getCapitalByCountryName(String countryName) { return Optional.of(countryService.findByName(countryName)) .map(Country::getCapital).orElseThrow(CountryNotFoundException::new); @@ -23,6 +24,4 @@ public class CountryServiceClient { return Optional.of(countryService.findByName(countryName)) .map(Country::getCurrency).orElseThrow(CountryNotFoundException::new); } - - } diff --git a/maven-modules/maven-plugins/jaxws/src/test/java/com/baeldung/soap/ws/client/CountryServiceClientUnitTest.java b/maven-modules/maven-plugins/jaxws/src/test/java/com/baeldung/soap/ws/client/CountryServiceClientUnitTest.java index b4e870415f..65c4f39ee4 100644 --- a/maven-modules/maven-plugins/jaxws/src/test/java/com/baeldung/soap/ws/client/CountryServiceClientUnitTest.java +++ b/maven-modules/maven-plugins/jaxws/src/test/java/com/baeldung/soap/ws/client/CountryServiceClientUnitTest.java @@ -18,14 +18,14 @@ class CountryServiceClientUnitTest { @DisplayName("Get capital by country name when country not found") @Test - void getCapitalByCountryName_WhenCountryDoesNotExists_ThenShouldThrowCountryNotFoundException() { + void givenCountryDoesNotExist_whenGetCapitalByCountryName_thenThrowsCountryNotFoundException() { doThrow(CountryNotFoundException.class).when(countryService).findByName(any()); Assertions.assertThrows(CountryNotFoundException.class, () -> countryServiceClient.getCapitalByCountryName(any())); } @DisplayName("Get capital by country name when country is India then should return capital") @Test - void getCapitalByCountryName_WhenCountryEqualsIndia_ThenShouldReturnCapital() { + void givenCountryIndia_whenGetCapitalByCountryName_thenShouldReturnCapital() { Country country = mock(Country.class); doReturn("New Delhi").when(country).getCapital(); @@ -36,14 +36,14 @@ class CountryServiceClientUnitTest { @DisplayName("Get population by country name when country not found") @Test - void getPopulationByCountryName_WhenCountryDoesNotExists_ThenShouldThrowCountryNotFoundException() { + void givenCountryDoesNotExist_getPopulationByCountryName_thenThrowsCountryNotFoundException() { doThrow(CountryNotFoundException.class).when(countryService).findByName(any()); Assertions.assertThrows(CountryNotFoundException.class, () -> countryServiceClient.getPopulationByCountryName(any())); } @DisplayName("Get population by country name when country is India then should return population") @Test - void getPopulationByCountryName_WhenCountryEqualsIndia_ThenShouldReturnPopulation() { + void givenCountryIndia_getPopulationByCountryName_thenShouldReturnPopulation() { Country country = mock(Country.class); doReturn(1000000).when(country).getPopulation(); @@ -54,14 +54,14 @@ class CountryServiceClientUnitTest { @DisplayName("Get currency by country name when country not found") @Test - void getCurrencyByCountryName_WhenCountryDoesNotExists_ThenShouldThrowCountryNotFoundException() { + void givenCountryDoesNotExist_getCurrencyByCountryName_thenThrowsCountryNotFoundException() { doThrow(CountryNotFoundException.class).when(countryService).findByName(any()); Assertions.assertThrows(CountryNotFoundException.class, () -> countryServiceClient.getCurrencyByCountryName(any())); } @DisplayName("Get currency by country name when country is India then should return currency") @Test - void getCurrencyByCountryName_WhenCountryEqualsIndia_ThenShouldReturnCurrency() { + void givenCountryIndia_getCurrencyByCountryName_thenShouldReturnCurrency() { Country country = mock(Country.class); doReturn(Currency.INR).when(country).getCurrency();