@Test public void getRightsWithoutPESModuleInstance() { InstanceInfo instanceInfoActe = this.instanceInfo("acte", "acte-service", "BUSINESS"); InstanceInfo instanceInfoConvocation = this.instanceInfo("convocation", "convocation-service", "BUSINESS"); Application applicationActe = this.application(instanceInfoActe, "acte-service"); Application applicationConvocation = this.application(instanceInfoConvocation, "convocation-service"); List<Application> applications = new ArrayList<>(); applications.add(applicationActe); applications.add(applicationConvocation); given(modulesService.activeBusinessApplications()).willReturn(applications); List<String> rights = rightsService.getRights(); WireMock.verify(2, getRequestedFor(urlPathMatching("/api/(acte|convocation)/rights"))); Assert.assertEquals(5, rights.size()); }
public List<String> getRights() { List<String> rights = new ArrayList<>(); modulesService.activeBusinessApplications().forEach(application -> { InstanceInfo instanceInfo = application.getInstances().get(0); String serviceName = modulesService.extractServiceName(application.getName()); try { String[] response = restTemplate.getForObject(this.buildRightsEndpointUrl(serviceName), String[].class); rights.addAll(Arrays.asList(Objects.requireNonNull(response))); } catch(RestClientException e) { LOGGER.warn("[getRights] An error occured in module {} : {}", application.getName(), e.getMessage()); } }); return rights; }
RightsService { public List<String> getRights() { List<String> rights = new ArrayList<>(); modulesService.activeBusinessApplications().forEach(application -> { InstanceInfo instanceInfo = application.getInstances().get(0); String serviceName = modulesService.extractServiceName(application.getName()); try { String[] response = restTemplate.getForObject(this.buildRightsEndpointUrl(serviceName), String[].class); rights.addAll(Arrays.asList(Objects.requireNonNull(response))); } catch(RestClientException e) { LOGGER.warn("[getRights] An error occured in module {} : {}", application.getName(), e.getMessage()); } }); return rights; } }
RightsService { public List<String> getRights() { List<String> rights = new ArrayList<>(); modulesService.activeBusinessApplications().forEach(application -> { InstanceInfo instanceInfo = application.getInstances().get(0); String serviceName = modulesService.extractServiceName(application.getName()); try { String[] response = restTemplate.getForObject(this.buildRightsEndpointUrl(serviceName), String[].class); rights.addAll(Arrays.asList(Objects.requireNonNull(response))); } catch(RestClientException e) { LOGGER.warn("[getRights] An error occured in module {} : {}", application.getName(), e.getMessage()); } }); return rights; } @Autowired  RightsService(RestTemplateBuilder builder, ModulesService modulesService, DiscoveryUtils discoveryUtils); }
RightsService { public List<String> getRights() { List<String> rights = new ArrayList<>(); modulesService.activeBusinessApplications().forEach(application -> { InstanceInfo instanceInfo = application.getInstances().get(0); String serviceName = modulesService.extractServiceName(application.getName()); try { String[] response = restTemplate.getForObject(this.buildRightsEndpointUrl(serviceName), String[].class); rights.addAll(Arrays.asList(Objects.requireNonNull(response))); } catch(RestClientException e) { LOGGER.warn("[getRights] An error occured in module {} : {}", application.getName(), e.getMessage()); } }); return rights; } @Autowired  RightsService(RestTemplateBuilder builder, ModulesService modulesService, DiscoveryUtils discoveryUtils); List<String> getRights(); }
RightsService { public List<String> getRights() { List<String> rights = new ArrayList<>(); modulesService.activeBusinessApplications().forEach(application -> { InstanceInfo instanceInfo = application.getInstances().get(0); String serviceName = modulesService.extractServiceName(application.getName()); try { String[] response = restTemplate.getForObject(this.buildRightsEndpointUrl(serviceName), String[].class); rights.addAll(Arrays.asList(Objects.requireNonNull(response))); } catch(RestClientException e) { LOGGER.warn("[getRights] An error occured in module {} : {}", application.getName(), e.getMessage()); } }); return rights; } @Autowired  RightsService(RestTemplateBuilder builder, ModulesService modulesService, DiscoveryUtils discoveryUtils); List<String> getRights();  }