DBInstanceImpl implements DBInstance { @Override public List<Bag> getBags() throws JasDBStorageException { return metadataStore.getBags(instanceMeta.getInstanceId()); } DBInstanceImpl(StorageServiceFactory storageServiceFactory, MetadataStore metadataStore, Instance instanceMeta); @Override String getInstanceId(); @Override List<Bag> getBags(); @Override Bag getBag(String bagName); @Override void removeBag(String bagName); @Override String getPath();  }
@Test public void testGetBags() throws JasDBStorageException { Bag bag1 = mock(Bag.class); Bag bag2 = mock(Bag.class); List<Bag> bagList = Lists.newArrayList(bag1, bag2); when(metadataStore.getBags("instance1")).thenReturn(bagList); when(instanceMeta.getInstanceId()).thenReturn("instance1"); DBInstanceImpl dbInstance = new DBInstanceImpl(storageServiceFactory, metadataStore, instanceMeta); assertThat(dbInstance.getBags().size(), is(2)); assertThat(dbInstance.getBags(), is(bagList)); }