public static Application mergeApplication(Application first, Application second) {
        if (!first.getName().equals(second.getName())) {
            throw new IllegalArgumentException("Cannot merge applications with different names");
        }
        Application merged = copyApplication(first);
        for (InstanceInfo instance : second.getInstances()) {
            switch (instance.getActionType()) {
                case ADDED:
                case MODIFIED:
                    merged.addInstance(instance);
                    break;
                case DELETED:
                    merged.removeInstance(instance);
            }
        }
        return merged;
    }
@Test
    public void testMergeApplicationIfActionTypeAddedReturnApplication() {
        Application application = createSingleInstanceApp("foo", "foo",
                InstanceInfo.ActionType.ADDED);
        Assert.assertEquals(application.getInstances(),
                EurekaEntityFunctions.mergeApplication(
                        application, application).getInstances());
    }