[SI-714] expand AddressServices by branch

Signed-off-by: Holger Rudolph <holger.rudolph@pta.de>
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/AddressController.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/AddressController.java
index 5f1a1ca..3e1778f 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/AddressController.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/AddressController.java
@@ -39,7 +39,7 @@
     private AddressService addressService;
 
     @Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-READER", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
-    @ApiOperation(value = "Anzeigen aller Addressen")
+    @ApiOperation(value = "Anzeigen aller Addressen nach Sparte (optional)")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
     @GetMapping
     public List<AddressDto> getAddresses(
@@ -58,60 +58,60 @@
         return addressService.getAdressByUuid(uuid);
     }
 
-    @ApiOperation(value = "Anzeige aller PLZs")
+    @ApiOperation(value = "Anzeige aller PLZs nach Sparte (optional)")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
     @GetMapping("/postcodes")
     @Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-READER", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
-    public List<String> findAllPostCodes() {
-        return addressService.getPostcodes();
+    public List<String> findAllPostCodes(@RequestParam("branch") Optional<String> branch) {
+        return addressService.getPostcodes(branch);
     }
 
-
-    @ApiOperation(value = "Anzeige eines Orte nach Postleitzahl")
+    @ApiOperation(value = "Anzeige aller Orte nach Postleitzahl und Sparte (optional)")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
     @GetMapping("/communities/{postcode}")
     @Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-READER", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
-    public List<String> findAllCommunitiesByPostcode(@PathVariable String postcode) {
-        return addressService.getCommunities(postcode);
+    public List<String> findAllCommunitiesByPostcode(
+            @PathVariable String postcode,
+            @RequestParam("branch") Optional<String> branch) {
+        return addressService.getCommunities(postcode, branch);
     }
 
-
-    @ApiOperation(value = "Anzeige Ortsteile nach Postleitzahl und Ort")
+    @ApiOperation(value = "Anzeige Ortsteile nach Postleitzahl und Ort und Sparte (optional)")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
     @GetMapping("/districts")
     @Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-READER", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
     public List<String> findDistricts(
             @RequestParam("postcode") String postcode,
-            @RequestParam("community") String community
+            @RequestParam("community") String community,
+            @RequestParam("branch") Optional<String> branch
     ) {
-        return addressService.getDistricts(postcode, community);
+        return addressService.getDistricts(postcode, community, branch);
     }
 
-
-    @ApiOperation(value = "Anzeige Strassen nach Postleitzahl und Ort und Ortsteil (optional)")
+    @ApiOperation(value = "Anzeige Strassen nach Postleitzahl und Ort und Ortsteil (optional) und Sparte (optional)")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
     @GetMapping("/streets")
     @Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-READER", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
     public List<String> findStreets(
             @RequestParam("postcode") String postcode,
             @RequestParam("community") String community,
-            @RequestParam("district") Optional<String> district
+            @RequestParam("district") Optional<String> district,
+            @RequestParam("branch") Optional<String> branch
     ) {
-        return addressService.getStreets(postcode, community, district);
+        return addressService.getStreets(postcode, community, district, branch);
     }
 
-
-
-    @ApiOperation(value = "Anzeige Strassen nach Postleitzahl und Ort und Strasse")
+    @ApiOperation(value = "Anzeige Hausnummern nach Postleitzahl und Ort und Strasse und Sparte (optional)")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "Erfolgreich durchgeführt")})
     @GetMapping("/housenumbers")
     @Secured({"ROLE_GRID-FAILURE-ADMIN", "ROLE_GRID-FAILURE-READER", "ROLE_GRID-FAILURE-CREATOR", "ROLE_GRID-FAILURE-QUALIFIER", "ROLE_GRID-FAILURE-PUBLISHER"})
     public List<HousenumberUuidDto> findHousenumbers(
             @RequestParam("postcode") String postcode,
             @RequestParam("community") String community,
-            @RequestParam("street") String street
+            @RequestParam("street") String street,
+            @RequestParam("branch") Optional<String> branch
     ) {
-        return addressService.getHousenumbers(postcode, community, street);
+        return addressService.getHousenumbers(postcode, community, street, branch);
     }
 
 }
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/AddressRepository.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/AddressRepository.java
index 615a8dd..b35e28f 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/AddressRepository.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/AddressRepository.java
@@ -34,25 +34,62 @@
 
     List<TblAddress> findByStationId(String stationId);
 
-    @Query("select distinct a.postcode from TblAddress a")
-    List<String> findAllPostcodes();
-
-    @Query("select distinct a.community from TblAddress a where postcode = :postcode")
-    List<String> findCommunitiesByPostcode(@Param("postcode") String postcode);
-
-    @Query("select distinct a.district from TblAddress a where postcode = :postcode and community = :community")
-    List<String> findDistrictsByPostcodeAndCommunity(@Param("postcode") String postcode, @Param("community") String community);
-
-    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community")
-    List<String> findStreetsByPostcodeAndCommunity(@Param("postcode") String postcode, @Param("community") String community);
-
-    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community and district = :district")
-    List<String> findStreetsByPostcodeAndCommunityAndDistrict(@Param("postcode") String postcode, @Param("community") String community, @Param("district") String district);
-
-    List<TblAddress> findByPostcodeAndCommunityAndStreet(String postcode, String community, String street);
-
     List<TblAddress> findByPowerConnection(Boolean powerConnection);
     List<TblAddress> findByWaterConnection(Boolean waterConnection);
     List<TblAddress> findByGasConnection(Boolean gasConnection);
 
+    @Query("select distinct a.postcode from TblAddress a")
+    List<String> findAllPostcodes();
+    @Query("select distinct a.postcode from TblAddress a where powerConnection = true")
+    List<String> findAllPostcodesForPower();
+    @Query("select distinct a.postcode from TblAddress a where gasConnection = true")
+    List<String> findAllPostcodesForGas();
+    @Query("select distinct a.postcode from TblAddress a where waterConnection = true")
+    List<String> findAllPostcodesForWater();
+
+    @Query("select distinct a.community from TblAddress a where postcode = :postcode")
+    List<String> findCommunitiesByPostcode(@Param("postcode") String postcode);
+    @Query("select distinct a.community from TblAddress a where postcode = :postcode and powerConnection = true")
+    List<String> findCommunitiesByPostcodeForPowerConnections(@Param("postcode") String postcode);
+    @Query("select distinct a.community from TblAddress a where postcode = :postcode and gasConnection = true")
+    List<String> findCommunitiesByPostcodeForGasConnections(@Param("postcode") String postcode);
+    @Query("select distinct a.community from TblAddress a where postcode = :postcode and waterConnection = true")
+    List<String> findCommunitiesByPostcodeForWaterConnections(@Param("postcode") String postcode);
+
+    @Query("select distinct a.district from TblAddress a where postcode = :postcode and community = :community")
+    List<String> findDistrictsByPostcodeAndCommunity(@Param("postcode") String postcode, @Param("community") String community);
+    @Query("select distinct a.district from TblAddress a where postcode = :postcode and community = :community and powerConnection = true")
+    List<String> findDistrictsByPostcodeAndCommunityForPower(@Param("postcode") String postcode, @Param("community") String community);
+    @Query("select distinct a.district from TblAddress a where postcode = :postcode and community = :community and gasConnection = true")
+    List<String> findDistrictsByPostcodeAndCommunityForGas(@Param("postcode") String postcode, @Param("community") String community);
+    @Query("select distinct a.district from TblAddress a where postcode = :postcode and community = :community and waterConnection = true")
+    List<String> findDistrictsByPostcodeAndCommunityForWater(@Param("postcode") String postcode, @Param("community") String community);
+
+    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community")
+    List<String> findStreetsByPostcodeAndCommunity(@Param("postcode") String postcode, @Param("community") String community);
+    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community and powerConnection = true")
+    List<String> findStreetsByPostcodeAndCommunityForPower(@Param("postcode") String postcode, @Param("community") String community);
+    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community and gasConnection = true")
+    List<String> findStreetsByPostcodeAndCommunityForGas(@Param("postcode") String postcode, @Param("community") String community);
+    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community and waterConnection = true")
+    List<String> findStreetsByPostcodeAndCommunityForWater(@Param("postcode") String postcode, @Param("community") String community);
+
+    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community and district = :district")
+    List<String> findStreetsByPostcodeAndCommunityAndDistrict(@Param("postcode") String postcode, @Param("community") String community, @Param("district") String district);
+    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community and district = :district and powerConnection = true")
+    List<String> findStreetsByPostcodeAndCommunityAndDistrictForPower(@Param("postcode") String postcode, @Param("community") String community, @Param("district") String district);
+    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community and district = :district and gasConnection = true")
+    List<String> findStreetsByPostcodeAndCommunityAndDistrictForGas(@Param("postcode") String postcode, @Param("community") String community, @Param("district") String district);
+    @Query("select distinct a.street from TblAddress a where postcode = :postcode and community = :community and district = :district and waterConnection = true")
+    List<String> findStreetsByPostcodeAndCommunityAndDistrictForWater(@Param("postcode") String postcode, @Param("community") String community, @Param("district") String district);
+
+    List<TblAddress> findByPostcodeAndCommunityAndStreet(String postcode, String community, String street);
+    @Query("select a from TblAddress a where postcode = :postcode and community = :community and street = :street and powerConnection = true")
+    List<TblAddress> findByPostcodeAndCommunityAndStreetForPower(String postcode, String community, String street);
+    @Query("select a from TblAddress a where postcode = :postcode and community = :community and street = :street and gasConnection = true")
+    List<TblAddress> findByPostcodeAndCommunityAndStreetForGas(String postcode, String community, String street);
+    @Query("select a from TblAddress a where postcode = :postcode and community = :community and street = :street and waterConnection = true")
+    List<TblAddress> findByPostcodeAndCommunityAndStreetForWater(String postcode, String community, String street);
+
+
 }
diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/AddressService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/AddressService.java
index 0fec162..5b5f947 100644
--- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/AddressService.java
+++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/AddressService.java
@@ -74,35 +74,130 @@
         return addressMapper.toAddressDto(tblAddress);
     }
 
-    public List<String> getPostcodes() {
-        return addressRepository.findAllPostcodes();
+    public List<String> getPostcodes(Optional<String> branchOpt) {
+        List<String> postcodeList;
+        String branch = branchOpt.orElseGet(String::new);
+
+        switch (branch) {
+            case "S":
+                postcodeList = addressRepository.findAllPostcodesForPower();
+                break;
+            case "G":
+                postcodeList = addressRepository.findAllPostcodesForGas();
+                break;
+            case "W":
+                postcodeList = addressRepository.findAllPostcodesForWater();
+                break;
+            default:
+                postcodeList = addressRepository.findAllPostcodes();
+        }
+
+        return postcodeList;
     }
 
-    public List<String> getCommunities(String postcode) {
-        return addressRepository.findCommunitiesByPostcode(postcode);
+    public List<String> getCommunities(String postcode, Optional<String> branchOpt) {
+        List<String> communityList;
+        String branch = branchOpt.orElseGet(String::new);
+
+        switch (branch) {
+            case "S":
+                communityList = addressRepository.findCommunitiesByPostcodeForPowerConnections(postcode);
+                break;
+            case "G":
+                communityList = addressRepository.findCommunitiesByPostcodeForGasConnections(postcode);
+                break;
+            case "W":
+                communityList = addressRepository.findCommunitiesByPostcodeForWaterConnections(postcode);
+                break;
+            default:
+                communityList = addressRepository.findCommunitiesByPostcode(postcode);
+        }
+
+        return communityList;
     }
 
-    public List<String> getDistricts(String postcode, String community) {
-        return addressRepository.findDistrictsByPostcodeAndCommunity(postcode, community);
+    public List<String> getDistricts(String postcode, String community, Optional<String> branchOpt) {
+        List<String> districtList;
+        String branch = branchOpt.orElseGet(String::new);
+
+        switch (branch) {
+            case "S":
+                districtList = addressRepository.findDistrictsByPostcodeAndCommunityForPower(postcode, community);
+                break;
+            case "G":
+                districtList = addressRepository.findDistrictsByPostcodeAndCommunityForGas(postcode, community);
+                break;
+            case "W":
+                districtList = addressRepository.findDistrictsByPostcodeAndCommunityForWater(postcode, community);
+                break;
+            default:
+                districtList = addressRepository.findDistrictsByPostcodeAndCommunity(postcode, community);
+        }
+        return districtList;
     }
 
-    public List<String> getStreets(String postcode, String community, Optional<String> district) {
+    public List<String> getStreets(String postcode, String community, Optional<String> district, Optional<String> branchOpt) {
+        List<String> streetList;
+        String branch = branchOpt.orElseGet(String::new);
 
         if (!district.isPresent()) {
-            return addressRepository.findStreetsByPostcodeAndCommunity(postcode, community);
+            switch (branch) {
+                case "S":
+                    streetList = addressRepository.findStreetsByPostcodeAndCommunityForPower(postcode, community);
+                    break;
+                case "G":
+                    streetList = addressRepository.findStreetsByPostcodeAndCommunityForGas(postcode, community);
+                    break;
+                case "W":
+                    streetList = addressRepository.findStreetsByPostcodeAndCommunityForWater(postcode, community);
+                    break;
+                default:
+                    streetList = addressRepository.findStreetsByPostcodeAndCommunity(postcode, community);
+            }
+            return streetList;
         } else {
-            return addressRepository.findStreetsByPostcodeAndCommunityAndDistrict(postcode, community, district.get());
+            switch (branch) {
+                case "S":
+                    streetList = addressRepository.findStreetsByPostcodeAndCommunityAndDistrictForPower(postcode, community, district.get());
+                    break;
+                case "G":
+                    streetList = addressRepository.findStreetsByPostcodeAndCommunityAndDistrictForGas(postcode, community, district.get());
+                    break;
+                case "W":
+                    streetList = addressRepository.findStreetsByPostcodeAndCommunityAndDistrictForWater(postcode, community, district.get());
+                    break;
+                default:
+                    streetList = addressRepository.findStreetsByPostcodeAndCommunityAndDistrict(postcode, community, district.get());
+            }
+            return streetList;
         }
+
     }
 
-    public List<HousenumberUuidDto> getHousenumbers(String postcode, String community, String street) {
+    public List<HousenumberUuidDto> getHousenumbers(String postcode, String community, String street, Optional<String> branchOpt) {
+        List<TblAddress> addressListList;
+        String branch = branchOpt.orElseGet(String::new);
 
-        return addressRepository.findByPostcodeAndCommunityAndStreet(postcode, community, street)
+        switch (branch) {
+            case "S":
+                addressListList = addressRepository.findByPostcodeAndCommunityAndStreetForPower(postcode, community, street);
+                break;
+            case "G":
+                addressListList = addressRepository.findByPostcodeAndCommunityAndStreetForGas(postcode, community, street);
+                break;
+            case "W":
+                addressListList = addressRepository.findByPostcodeAndCommunityAndStreetForWater(postcode, community, street);
+                break;
+            default:
+                addressListList = addressRepository.findByPostcodeAndCommunityAndStreet(postcode, community, street);
+        }
+        return addressListList
                 .stream()
                 .map(AddressService::toHousenumberUuid)
                 .collect(collectingAndThen(toCollection(() -> new TreeSet<>(Comparator.comparing(HousenumberUuidDto::getHousenumber))),
                         ArrayList::new));
 
+
     }
 
 
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/AddressControllerTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/AddressControllerTest.java
index 75a8287..b3ade7c 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/AddressControllerTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/AddressControllerTest.java
@@ -49,35 +49,38 @@
 
     @Test
     public void shouldReturnPostCodes() throws Exception {
+        Optional<String> branchOptional = Optional.empty();
         List<String> postcodes = MockDataHelper.mockPostCodes();
-        when(addressService.getPostcodes()).thenReturn(postcodes);
+        when(addressService.getPostcodes(branchOptional)).thenReturn(postcodes);
 
         mockMvc.perform(get("/addresses/postcodes"))
                 .andExpect(status().is2xxSuccessful())
                 .andExpect(content().contentType(MediaType.APPLICATION_JSON));
 
-        verify(addressService, times(1)).getPostcodes();
+        verify(addressService, times(1)).getPostcodes(branchOptional);
     }
 
     @Test
     public void shouldReturnCommunities() throws Exception {
         String postcode = "71111";
+        Optional<String> branchOptional = Optional.empty();
         List<String> strings = MockDataHelper.mockStringList();
-        when(addressService.getCommunities(postcode)).thenReturn(strings);
+        when(addressService.getCommunities(postcode, branchOptional)).thenReturn(strings);
 
         mockMvc.perform(get("/addresses/communities/" + postcode))
                 .andExpect(status().is2xxSuccessful())
                 .andExpect(content().contentType(MediaType.APPLICATION_JSON));
 
-        verify(addressService, times(1)).getCommunities(postcode);
+        verify(addressService, times(1)).getCommunities(postcode, branchOptional);
     }
 
     @Test
     public void shouldReturnDistricts() throws Exception {
         String postcode = "71111";
         String community = "com1";
+        Optional<String> branchOptional = Optional.empty();
         List<String> strings = MockDataHelper.mockStringList();
-        when(addressService.getDistricts(postcode, community)).thenReturn(strings);
+        when(addressService.getDistricts(postcode, community, branchOptional)).thenReturn(strings);
 
         mockMvc.perform(
                     get("/addresses/districts")
@@ -87,7 +90,7 @@
                 .andExpect(status().is2xxSuccessful())
                 .andExpect(content().contentType(MediaType.APPLICATION_JSON));
 
-        verify(addressService, times(1)).getDistricts(postcode, community);
+        verify(addressService, times(1)).getDistricts(postcode, community, branchOptional);
     }
 
     @Test
@@ -95,8 +98,9 @@
         String postcode = "71111";
         String community = "com1";
         Optional<String> district = Optional.of("district1");
+        Optional<String> branchOptional = Optional.empty();
         List<String> strings = MockDataHelper.mockStringList();
-        when(addressService.getStreets(postcode, community, district)).thenReturn(strings);
+        when(addressService.getStreets(postcode, community, district, branchOptional)).thenReturn(strings);
 
         mockMvc.perform(
                     get("/addresses/streets")
@@ -107,7 +111,7 @@
                 .andExpect(status().is2xxSuccessful())
                 .andExpect(content().contentType(MediaType.APPLICATION_JSON));
 
-        verify(addressService, times(1)).getStreets(postcode, community, district);
+        verify(addressService, times(1)).getStreets(postcode, community, district, branchOptional);
     }
 
     @Test
@@ -115,8 +119,9 @@
         String postcode = "71111";
         String community = "com1";
         String street = "street1";
+        Optional<String> branchOptional = Optional.empty();
         List<HousenumberUuidDto> housenumberUuidDtos = MockDataHelper.mockHousnumberUuidList();
-        when(addressService.getHousenumbers(postcode, community, street)).thenReturn(housenumberUuidDtos);
+        when(addressService.getHousenumbers(postcode, community, street, branchOptional)).thenReturn(housenumberUuidDtos);
 
         mockMvc.perform(
                 get("/addresses/housenumbers")
@@ -127,6 +132,6 @@
                 .andExpect(status().is2xxSuccessful())
                 .andExpect(content().contentType(MediaType.APPLICATION_JSON));
 
-        verify(addressService, times(1)).getHousenumbers(postcode, community, street);
+        verify(addressService, times(1)).getHousenumbers(postcode, community, street, branchOptional);
     }
 }
\ No newline at end of file
diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/AddressServiceTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/AddressServiceTest.java
index be9b117..54eed0e 100644
--- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/AddressServiceTest.java
+++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/AddressServiceTest.java
@@ -106,9 +106,10 @@
 
     @Test
     public void shouldGetPostcodes() {
+        Optional<String> branchOptional = Optional.empty();
         List<String> strings = MockDataHelper.mockStringList();
         when(addressRepository.findAllPostcodes()).thenReturn(strings);
-        List<String> postCodes = addressService.getPostcodes();
+        List<String> postCodes = addressService.getPostcodes(branchOptional);
 
         assertEquals(postCodes.size(), strings.size());
         assertEquals(2, postCodes.size());
@@ -118,9 +119,10 @@
     @Test
     public void shouldGetCommunities() {
         String postcode = "12345";
+        Optional<String> branchOptional = Optional.empty();
         List<String> strings = MockDataHelper.mockStringList();
         when(addressRepository.findCommunitiesByPostcode(postcode)).thenReturn(strings);
-        List<String> communities = addressService.getCommunities(postcode);
+        List<String> communities = addressService.getCommunities(postcode, branchOptional);
 
         assertEquals(communities.size(), strings.size());
         assertEquals(2, communities.size());
@@ -131,9 +133,10 @@
     public void shouldGetDistricts() {
         String postcode = "12345";
         String community = "com1";
+        Optional<String> branchOptional = Optional.empty();
         List<String> strings = MockDataHelper.mockStringList();
         when(addressRepository.findDistrictsByPostcodeAndCommunity(postcode, community)).thenReturn(strings);
-        List<String> districts = addressService.getDistricts(postcode, community);
+        List<String> districts = addressService.getDistricts(postcode, community, branchOptional);
 
         assertEquals(districts.size(), strings.size());
         assertEquals(2, districts.size());
@@ -145,12 +148,13 @@
         String postcode = "12345";
         String community = "com1";
         String street = "street1";
+        Optional<String> branchOptional = Optional.empty();
         List<HousenumberUuidDto> housenumberUuids = MockDataHelper.mockHousnumberUuidList();
         List<TblAddress> tblAddresses = MockDataHelper.mockAddressList();
 
         when(addressRepository.findByPostcodeAndCommunityAndStreet(postcode, community, street)).thenReturn(tblAddresses);
 
-        List<HousenumberUuidDto> housenumbers = addressService.getHousenumbers(postcode, community, street);
+        List<HousenumberUuidDto> housenumbers = addressService.getHousenumbers(postcode, community, street, branchOptional);
 
         assertEquals(housenumbers.size(), housenumberUuids.size());
         assertEquals(2, housenumbers.size());
@@ -162,9 +166,10 @@
         String postcode = "12345";
         String community = "com1";
         Optional<String> district = Optional.empty();
+        Optional<String> branchOptional = Optional.empty();
         List<String> strings = MockDataHelper.mockStringList();
         when(addressRepository.findStreetsByPostcodeAndCommunity(postcode, community)).thenReturn(strings);
-        List<String> streets = addressService.getStreets(postcode, community, district);
+        List<String> streets = addressService.getStreets(postcode, community, district, branchOptional);
 
         assertEquals(streets.size(), strings.size());
         assertEquals(2, streets.size());
@@ -176,10 +181,11 @@
         String postcode = "12345";
         String community = "com1";
         String district = "test1";
+        Optional<String> branchOptional = Optional.empty();
         Optional<String> optionalDistrict = Optional.of("test1");
         List<String> strings = MockDataHelper.mockStringList();
         when(addressRepository.findStreetsByPostcodeAndCommunityAndDistrict(postcode, community, district)).thenReturn(strings);
-        List<String> streets = addressService.getStreets(postcode, community, optionalDistrict);
+        List<String> streets = addressService.getStreets(postcode, community, optionalDistrict, branchOptional);
 
         assertEquals(streets.size(), strings.size());
         assertEquals(2, streets.size());