public static InstanceInfo selectInstance(Applications applications, String id) {
        for (Application application : applications.getRegisteredApplications()) {
            for (InstanceInfo instance : application.getInstances()) {
                if (instance.getId().equals(id)) {
                    return instance;
                }
            }
        }
        return null;
    }
@Test
    public void testSelectInstanceIfInstanceExistsReturnSelectedInstance() {
        Application application = createSingleInstanceApp("foo", "foo",
                InstanceInfo.ActionType.ADDED);
        Applications applications = createApplications(application);

        Assert.assertNull(EurekaEntityFunctions
                .selectInstance(new Applications(), "foo"));
        Assert.assertNull(EurekaEntityFunctions
                .selectInstance(new Applications(), "foo", "foo"));

        Assert.assertEquals(application.getByInstanceId("foo"),
                EurekaEntityFunctions.selectInstance(applications, "foo"));
        Assert.assertEquals(application.getByInstanceId("foo"),
                EurekaEntityFunctions.selectInstance(applications, "foo", "foo"));
    }