use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class EurekaEntityFunctionsTest method testMergeApplicationIfActionTypeModifiedReturnApplication.
@Test
public void testMergeApplicationIfActionTypeModifiedReturnApplication() {
Application application = createSingleInstanceApp("foo", "foo", InstanceInfo.ActionType.MODIFIED);
Assert.assertEquals(application.getInstances(), EurekaEntityFunctions.mergeApplication(application, application).getInstances());
}
use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class EurekaEntityFunctionsTest method testSelectInstancesMappedByIdIfNotNullReturnMapOfInstances.
@Test
public void testSelectInstancesMappedByIdIfNotNullReturnMapOfInstances() {
Application application = createSingleInstanceApp("foo", "foo", InstanceInfo.ActionType.ADDED);
HashMap<String, InstanceInfo> hashMap = new HashMap<>();
hashMap.put("foo", application.getByInstanceId("foo"));
Assert.assertEquals(hashMap, EurekaEntityFunctions.selectInstancesMappedById(application));
}
use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class EurekaEntityFunctionsTest method testToApplicationMapIfNotNullReturnMapOfApplication.
@Test
public void testToApplicationMapIfNotNullReturnMapOfApplication() {
Application application = createSingleInstanceApp("foo", "foo", InstanceInfo.ActionType.ADDED);
Assert.assertEquals(1, EurekaEntityFunctions.toApplicationMap(new ArrayList<>(Arrays.asList(application.getByInstanceId("foo")))).size());
}
use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class EurekaEntityFunctionsTest method createSingleInstanceApp.
private Application createSingleInstanceApp(String appId, String instanceId, InstanceInfo.ActionType actionType) {
InstanceInfo instanceInfo = Mockito.mock(InstanceInfo.class);
Mockito.when(instanceInfo.getId()).thenReturn(instanceId);
Mockito.when(instanceInfo.getAppName()).thenReturn(instanceId);
Mockito.when(instanceInfo.getStatus()).thenReturn(InstanceInfo.InstanceStatus.UP);
Mockito.when(instanceInfo.getActionType()).thenReturn(actionType);
Application application = new Application(appId);
application.addInstance(instanceInfo);
return application;
}
use of com.netflix.discovery.shared.Application in project eureka by Netflix.
the class EurekaEntityFunctionsTest method testCountInstancesIfApplicationsHasInstancesReturnSize.
@Test
public void testCountInstancesIfApplicationsHasInstancesReturnSize() {
Application application = createSingleInstanceApp("foo", "foo", InstanceInfo.ActionType.ADDED);
Applications applications = createApplications(application);
Assert.assertEquals(1, EurekaEntityFunctions.countInstances(applications));
}
Aggregations