@Test @DisplayName("Reads persistent group data") void testReadGroupData(@Mock Storage storage, @Mock DatabaseAccessor accessor) throws Exception { when(group.getName()).thenReturn("test.new.data"); when(storageProvider.exists(any())).thenReturn(true); when(storageProvider.read(any())).thenReturn(storage); when(databaseProvider.read(any())).thenReturn(accessor); when(accessor.getData()).thenAnswer(__ -> Stream.of( event("none", "1", "ADD", "{\"param\":\"value\"}", LocalDateTime.now()), event("none", "2", "ADD", "{\"param\":\"value\"}", LocalDateTime.now()), event("none", "1", "REPLACE", "{\"param\":\"value\"}", LocalDateTime.now()))); GroupData groupData = dataStore.getGroupData(group); assertThat(groupData).isInstanceOf(PersistedGroupData.class); assertThat(groupData.getGroup()).isSameAs(group); assertThat(groupData.getEntries()).hasSize(2); verify(storageProvider).read("test.new.data"); verify(databaseProvider).read(storage); }
@Override public GroupData getGroupData(InMemoryGroup group) { try { return getGroupData0(group); } catch (DatabaseException exc) { throw new IllegalStateException(exc); } }
PersistedGroupDataStore implements GroupDataStore { @Override public GroupData getGroupData(InMemoryGroup group) { try { return getGroupData0(group); } catch (DatabaseException exc) { throw new IllegalStateException(exc); } } }
PersistedGroupDataStore implements GroupDataStore { @Override public GroupData getGroupData(InMemoryGroup group) { try { return getGroupData0(group); } catch (DatabaseException exc) { throw new IllegalStateException(exc); } } PersistedGroupDataStore(StorageProvider storageProvider);  PersistedGroupDataStore(StorageProvider storageProvider, DatabaseProvider provider); }
PersistedGroupDataStore implements GroupDataStore { @Override public GroupData getGroupData(InMemoryGroup group) { try { return getGroupData0(group); } catch (DatabaseException exc) { throw new IllegalStateException(exc); } } PersistedGroupDataStore(StorageProvider storageProvider);  PersistedGroupDataStore(StorageProvider storageProvider, DatabaseProvider provider); @Override GroupData getGroupData(InMemoryGroup group); }
PersistedGroupDataStore implements GroupDataStore { @Override public GroupData getGroupData(InMemoryGroup group) { try { return getGroupData0(group); } catch (DatabaseException exc) { throw new IllegalStateException(exc); } } PersistedGroupDataStore(StorageProvider storageProvider);  PersistedGroupDataStore(StorageProvider storageProvider, DatabaseProvider provider); @Override GroupData getGroupData(InMemoryGroup group);  }