Java Code Examples for com.netflix.discovery.shared.Applications#addApplication()

The following examples show how to use com.netflix.discovery.shared.Applications#addApplication() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApplicationRegistry.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Add new route to a service.
 *
 * @param service    Details of the service to be registered in the Gateway
 * @param addTimeout Whether the custom metadata should be provided for given service.
 */
public void addApplication(Service service, boolean addTimeout, boolean corsEnabled) {
    String id = service.getId();
    String locationPattern = service.getLocationPattern();
    String serviceRoute = service.getServiceRoute();

    Applications applications = new Applications();
    Application withMetadata = new Application(id);

    Map<String, String> metadata = createMetadata(addTimeout, corsEnabled);

    withMetadata.addInstance(getStandardInstance(metadata, id));
    applications.addApplication(withMetadata);
    ZuulProperties.ZuulRoute route = new ZuulProperties.ZuulRoute(locationPattern, service.getId());
    zuulRouteLinkedHashMap.put(locationPattern, route);

    applicationsToReturn.put(id, applications);

    RoutedServices routedServices = new RoutedServices();
    routedServices.addRoutedService(new RoutedService("test", serviceRoute, ""));
    if (this.routedServicesUsers != null) {
        for (RoutedServicesUser routedServicesUser : routedServicesUsers) {
            routedServicesUser.addRoutedServices(id, routedServices);
        }
    } else {
        servicesToAdd.add(new Services(id, routedServices));
    }
}
 
Example 2
Source File: ServiceControllerTest.java    From eureka-consul-adapter with MIT License 5 votes vote down vote up
private Applications mock2Applications() {
    Applications applications = new Applications();
    Application app1 = new Application();
    app1.setName("ms1");
    applications.addApplication(app1);
    Application app2 = new Application();
    app2.setName("ms2");
    applications.addApplication(app2);

    return applications;
}
 
Example 3
Source File: EurekaServerMockApplication.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@GetMapping({ "/apps", "/apps/delta", "/vips/{address}", "/svips/{address}" })
public Applications getApplications(@PathVariable(required = false) String address,
		@RequestParam(required = false) String regions) {
	Applications applications = new Applications();
	applications
			.addApplication(new Application("app1", Collections.singletonList(INFO)));
	return applications;
}
 
Example 4
Source File: EurekaReactiveDiscoveryClientTests.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnEmptyFluxOfServicesWhenNoInstancesFound() {
	Applications applications = new Applications();
	applications.addApplication(new Application("my-service"));
	when(eurekaClient.getApplications()).thenReturn(applications);
	Flux<String> services = this.client.getServices();
	StepVerifier.create(services).expectNextCount(0).expectComplete().verify();
}
 
Example 5
Source File: EurekaReactiveDiscoveryClientTests.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnFluxOfServices() {
	Applications applications = new Applications();
	Application app = new Application("my-service");
	app.addInstance(new InstanceInfo("instance", "my-service", "", "127.0.0.1", "",
			null, null, "", "", "", "", "", "", 0, null, "", null, null, null, null,
			null, null, null, null, null, null));
	applications.addApplication(app);
	when(eurekaClient.getApplications()).thenReturn(applications);
	Flux<String> services = this.client.getServices();
	StepVerifier.create(services).expectNext("my-service").expectComplete().verify();
}