CompositePersistence implements Persistence<O, A> { @Override public ObjectStore<O> createObjectStore() { return primaryPersistence.createObjectStore(); } CompositePersistence(Persistence<O, A> primaryPersistence, Persistence<O, A> secondaryPersistence, List<? extends Persistence<O, A>> additionalPersistences); @Override SimpleAttribute<O, A> getPrimaryKeyAttribute(); @Override boolean supportsIndex(Index<O> index); Persistence<O, A> getPersistenceForIndex(Index<O> index); @Override ObjectStore<O> createObjectStore(); Persistence<O, A> getPrimaryPersistence(); Persistence<O, A> getSecondaryPersistence(); List<? extends Persistence<O, A>> getAdditionalPersistences(); @Override void openRequestScopeResources(QueryOptions queryOptions); @Override void closeRequestScopeResources(QueryOptions queryOptions); static CompositePersistence<O, A> of(Persistence<O, A> primaryPersistence, Persistence<O, A> secondaryPersistence, List<? extends Persistence<O, A>> additionalPersistences); static CompositePersistence<O, A> of(Persistence<O, A> primaryPersistence, Persistence<O, A> secondaryPersistence);  }
@Test public void testCreateObjectStore() throws Exception { Persistence<Car, Integer> persistence1 = mockPersistence("persistence1"); Persistence<Car, Integer> persistence2 = mockPersistence("persistence2"); Persistence<Car, Integer> persistence3 = mockPersistence("persistence3"); when(persistence1.getPrimaryKeyAttribute()).thenReturn(Car.CAR_ID); when(persistence2.getPrimaryKeyAttribute()).thenReturn(Car.CAR_ID); when(persistence3.getPrimaryKeyAttribute()).thenReturn(Car.CAR_ID); ObjectStore<Car> objectStore = new ConcurrentOnHeapObjectStore<Car>(); when(persistence1.createObjectStore()).thenReturn(objectStore); CompositePersistence<Car, Integer> compositePersistence = new CompositePersistence<Car, Integer>(persistence1, persistence2, singletonList(persistence3)); ObjectStore<Car> result = compositePersistence.createObjectStore(); assertEquals(objectStore, result); }