public static Applications mergeApplications(Applications first, Applications second) {
        Set<String> firstNames = selectApplicationNames(first);
        Set<String> secondNames = selectApplicationNames(second);
        Set<String> allNames = new HashSet<>(firstNames);
        allNames.addAll(secondNames);

        Applications merged = new Applications();
        for (String appName : allNames) {
            if (firstNames.contains(appName)) {
                if (secondNames.contains(appName)) {
                    merged.addApplication(mergeApplication(first.getRegisteredApplications(appName), second.getRegisteredApplications(appName)));
                } else {
                    merged.addApplication(copyApplication(first.getRegisteredApplications(appName)));
                }
            } else {
                merged.addApplication(copyApplication(second.getRegisteredApplications(appName)));
            }
        }
        return updateMeta(merged);
    }
@Test
    public void
    testMergeApplicationsIfNotNullAndHasAppNameReturnApplications() {
        Application application = createSingleInstanceApp("foo", "foo",
                InstanceInfo.ActionType.ADDED);
        Applications applications = createApplications(application);
        Assert.assertEquals(1, EurekaEntityFunctions.mergeApplications(
                applications, applications).size());
    }