DBInstanceFactoryImpl implements DBInstanceFactory { @Override public List<DBInstance> listInstances() { return new ArrayList<>(this.instances.values()); } @Autowired  DBInstanceFactoryImpl(MetadataStore metadataStore, StorageServiceFactory storageServiceFactory); @Override void addInstance(String instanceId); @Override void deleteInstance(String instanceId); @Override DBInstance getInstance(); @Override DBInstance getInstance(String instanceId); @Override boolean hasInstance(String instanceId); @Override List<DBInstance> listInstances(); @Override void shutdown();  }
@Test public void testLoadInstances() throws JasDBStorageException { Instance instance1 = mock(Instance.class); Instance instance2 = mock(Instance.class); when(instance1.getInstanceId()).thenReturn(INSTANCE_1); when(instance2.getInstanceId()).thenReturn("instance2"); when(metadataStore.getInstances()).thenReturn(Lists.newArrayList(instance1, instance2)); DBInstanceFactoryImpl instanceFactory = new DBInstanceFactoryImpl(metadataStore, storageServiceFactory); assertThat(instanceFactory.listInstances().size(), is(2)); assertThat(getInstanceIds(instanceFactory.listInstances()), hasItems(INSTANCE_1, "instance2")); }