Search in sources :

Example 86 with Application

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());
}
Also used : Application(com.netflix.discovery.shared.Application) Test(org.junit.Test)

Example 87 with Application

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));
}
Also used : HashMap(java.util.HashMap) Application(com.netflix.discovery.shared.Application) InstanceInfo(com.netflix.appinfo.InstanceInfo) Test(org.junit.Test)

Example 88 with 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());
}
Also used : Application(com.netflix.discovery.shared.Application) Test(org.junit.Test)

Example 89 with Application

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;
}
Also used : InstanceInfo(com.netflix.appinfo.InstanceInfo) Application(com.netflix.discovery.shared.Application)

Example 90 with 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));
}
Also used : Applications(com.netflix.discovery.shared.Applications) Application(com.netflix.discovery.shared.Application) Test(org.junit.Test)

Aggregations

Application (com.netflix.discovery.shared.Application)104 InstanceInfo (com.netflix.appinfo.InstanceInfo)51 Test (org.junit.Test)43 Applications (com.netflix.discovery.shared.Applications)41 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)14 DecoderWrapper (com.netflix.discovery.converters.wrappers.DecoderWrapper)7 Response (javax.ws.rs.core.Response)7 CodecWrappers (com.netflix.discovery.converters.wrappers.CodecWrappers)6 Map (java.util.Map)6 DiscoveryNode (com.hazelcast.spi.discovery.DiscoveryNode)4 Lease (com.netflix.eureka.lease.Lease)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InputStream (java.io.InputStream)3 AmazonInfo (com.netflix.appinfo.AmazonInfo)2 InstanceStatus (com.netflix.appinfo.InstanceInfo.InstanceStatus)2 Pair (com.netflix.discovery.shared.Pair)2