DBInstanceImpl implements DBInstance { @Override public Bag getBag(String bagName) throws JasDBStorageException { return metadataStore.getBag(instanceMeta.getInstanceId(), bagName); } 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 testGetBag() throws JasDBStorageException { Bag bag = mock(Bag.class); when(metadataStore.getBag("instance1", "bag")).thenReturn(bag); when(instanceMeta.getInstanceId()).thenReturn("instance1"); DBInstanceImpl dbInstance = new DBInstanceImpl(storageServiceFactory, metadataStore, instanceMeta); Bag retrievedBag = dbInstance.getBag("bag"); assertThat(retrievedBag, is(bag)); }