@Test public void instanceStoreShouldCreateANewInstance() { IdentifierSourceSet identifierSourceSet = mock(IdentifierSourceSet.class); IdentifierSource identifierSource = mock(IdentifierSource.class); InstanceDomain instanceDomain = mock(InstanceDomain.class); PcpStringStore stringStore = mock(PcpStringStore.class); PcpString pcpString = mock(PcpString.class); when(identifierSourceSet.instanceSource(INSTANCE_NAME)).thenReturn(identifierSource); when(identifierSource.calculateId(eq(INSTANCE_NAME), ArgumentMatchers.<Integer>anySet())).thenReturn(123); when(stringStore.createPcpString(INSTANCE_NAME)).thenReturn(pcpString); InstanceV2.InstanceStoreV2 instanceStore = new InstanceV2.InstanceStoreV2(identifierSourceSet, INSTANCE_NAME, instanceDomain, stringStore); Instance actual = instanceStore.byName(INSTANCE_NAME); InstanceV2 expected = new InstanceV2(instanceDomain, INSTANCE_NAME, 123, pcpString); assertReflectionEquals(expected, actual); }
@Test public void shouldCreateANewInstanceStoreV2() { IdentifierSourceSet identifierSourceSet = mock(IdentifierSourceSet.class); PcpStringStore stringStore = mock(PcpStringStore.class); InstanceDomain instanceDomain = mock(InstanceDomain.class); InstanceStoreFactory instanceStoreFactory = new InstanceStoreFactoryV2(identifierSourceSet, stringStore); Store<Instance> actual = instanceStoreFactory.createNewInstanceStore(STORE_NAME, instanceDomain); Store<Instance> expected = new InstanceV2.InstanceStoreV2(identifierSourceSet, STORE_NAME, instanceDomain, stringStore); assertReflectionEquals(expected, actual); }
@Override public Store<Instance> createNewInstanceStore(String name, InstanceDomain instanceDomain) { return new InstanceStoreV2(identifierSourceSet, name, instanceDomain, stringStore); }