AutosleepCatalogBuilder { @Bean public Catalog buildCatalog() { String serviceBrokerId = environment.getProperty(Config.EnvKey.CF_SERVICE_BROKER_ID, Config.ServiceCatalog.DEFAULT_SERVICE_BROKER_ID); String serviceBrokerName = environment.getProperty(EnvKey.CF_SERVICE_BROKER_NAME, Config.ServiceCatalog.DEFAULT_SERVICE_BROKER_NAME); String servicePlanId = environment.getProperty(Config.EnvKey.CF_SERVICE_PLAN_ID, Config.ServiceCatalog.DEFAULT_SERVICE_PLAN_ID); String servicePlanName = environment.getProperty(EnvKey.CF_SERVICE_PLAN_NAME, Config.ServiceCatalog.DEFAULT_SERVICE_PLAN_NAME); return new Catalog(Collections.singletonList(new ServiceDefinition( serviceBrokerId, serviceBrokerName, "Automatically stops inactive apps", true, false, Collections.singletonList( new Plan(servicePlanId, servicePlanName, "Autosleep default plan", null, true)), Arrays.asList("autosleep", "document"), getServiceDefinitionMetadata(), Collections.singletonList(ServiceDefinitionRequires.SERVICE_REQUIRES_ROUTE_FORWARDING.toString()), null))); }  @Bean Catalog buildCatalog();  }
@Test public void test_catalog_is_built() { when(environment.getProperty(eq(Config.EnvKey.CF_SERVICE_BROKER_ID), anyString())) .thenReturn(SERVICE_BROKER_ID); when(environment.getProperty(eq(EnvKey.CF_SERVICE_PLAN_ID), anyString())) .thenReturn(SERVICE_PLAN_ID); Catalog catalog = catalogBuilder.buildCatalog(); assertThat(catalog.getServiceDefinitions().size(), is(equalTo(1))); ServiceDefinition serviceDefinition = catalog.getServiceDefinitions().get(0); assertThat(serviceDefinition.getId(), is(equalTo(SERVICE_BROKER_ID))); assertThat(serviceDefinition.getPlans().size(), is(equalTo(1))); assertTrue(serviceDefinition.isBindable()); assertFalse(serviceDefinition.isPlanUpdateable()); Plan plan = serviceDefinition.getPlans().get(0); assertThat(plan.getId(), is(equalTo(SERVICE_PLAN_ID))); assertTrue(plan.isFree()); assertThat(serviceDefinition.getDashboardClient(), is(nullValue())); }