use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class ApplicationsResourceTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
InstanceInfoGenerator instanceInfos = InstanceInfoGenerator.newBuilder(20, 6).build();
testApplications = instanceInfos.toApplications();
applicationsResource = new ApplicationsResource(serverContext);
for (Application application : testApplications.getRegisteredApplications()) {
for (InstanceInfo instanceInfo : application.getInstances()) {
registry.register(instanceInfo, false);
}
}
}
use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class InstanceRegistryTest method testGetAppsFromAllRemoteRegions.
@Test
public void testGetAppsFromAllRemoteRegions() throws Exception {
Applications apps = registry.getApplicationsFromAllRemoteRegions();
List<Application> registeredApplications = apps.getRegisteredApplications();
Assert.assertEquals("Apps size from remote regions do not match", 1, registeredApplications.size());
Application app = registeredApplications.iterator().next();
Assert.assertEquals("Added app did not return from remote registry", REMOTE_REGION_APP_NAME, app.getName());
Assert.assertEquals("Returned app did not have the instance", 1, app.getInstances().size());
}
use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class AbstractVIPResourceTest method testFullVipGet.
@Test
public void testFullVipGet() throws Exception {
Response response = resource.getVipResponse(Version.V2.name(), vipName, MediaType.APPLICATION_JSON, EurekaAccept.full, Key.EntityType.VIP);
String json = String.valueOf(response.getEntity());
DecoderWrapper decoder = CodecWrappers.getDecoder(CodecWrappers.LegacyJacksonJson.class);
Applications decodedApps = decoder.decode(json, Applications.class);
Application decodedApp = decodedApps.getRegisteredApplications(testApplication.getName());
assertThat(EurekaEntityComparators.equal(testApplication, decodedApp), is(true));
}
use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class ApplicationFunctions method toApplicationMap.
public static Map<String, Application> toApplicationMap(List<InstanceInfo> instances) {
Map<String, Application> applicationMap = new HashMap<String, Application>();
for (InstanceInfo instance : instances) {
String appName = instance.getAppName();
Application application = applicationMap.get(appName);
if (application == null) {
applicationMap.put(appName, application = new Application(appName));
}
application.addInstance(instance);
}
return applicationMap;
}
use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class InstanceInfoGenerator method toApplications.
public Applications toApplications() {
Map<String, Application> appsByName = new HashMap<>();
Iterator<InstanceInfo> it = serviceIterator();
while (it.hasNext()) {
InstanceInfo instanceInfo = it.next();
Application instanceApp = appsByName.get(instanceInfo.getAppName());
if (instanceApp == null) {
instanceApp = new Application(instanceInfo.getAppName());
appsByName.put(instanceInfo.getAppName(), instanceApp);
}
instanceApp.addInstance(instanceInfo);
}
// Do not pass application list to the constructor, as it does not initialize properly Applications
// data structure.
Applications applications = new Applications();
for (Application app : appsByName.values()) {
applications.addApplication(app);
}
applications.shuffleInstances(false);
applications.setAppsHashCode(applications.getReconcileHashCode());
applications.setVersion(1L);
return applications;
}
Aggregations