InstanceDomain implements PcpId, PcpOffset, MmvWritable { Collection<Instance> getInstances() { return instanceStore.all(); } InstanceDomain(String name, int id, InstanceStoreFactory instanceStoreFactory); @Override String toString(); int getId(); int getOffset(); void setOffset(int offset); @Override int byteSize(); @Override void writeToMmv(ByteBuffer byteBuffer);  }
@Test public void shouldReturnInstancesAssociatedWithTheStore() { InstanceStoreFactory instanceStoreFactory = mock(InstanceStoreFactory.class); Store<Instance> instanceStore = mock(Store.class); Collection<Instance> instances = singletonList(mock(Instance.class)); when(instanceStoreFactory.createNewInstanceStore(eq(DOMAIN), any(InstanceDomain.class))).thenReturn(instanceStore); when(instanceStore.all()).thenReturn(instances); InstanceDomain instanceDomain = new InstanceDomain(DOMAIN, 111, instanceStoreFactory); assertThat(instanceDomain.getInstances(), is(instances)); }