@Test @DisplayName("Adds initial entries to created group data") void testAddInitialData(@Mock DatabaseAccessor accessor) throws Exception { when(group.getName()).thenReturn("test.new.data"); when(storageProvider.exists(any())).thenReturn(false); when(databaseProvider.create(any(), anyString())).thenReturn(accessor); when(group.validateNewEntry(any(), any())).then(returnsFirstArg()); when(group.initialData()).thenReturn(Arrays.asList( DefaultEntryData.of("id1", TestMap.of("param", "value1")), DefaultEntryData.of("id2", TestMap.of("param", "value2")) )); GroupData groupData = dataStore.getGroupData(group); assertThat(groupData).isInstanceOf(PersistedGroupData.class); assertThat(groupData.getGroup()).isSameAs(group); verify(databaseProvider).create(storageProvider, "test.new.data"); ArgumentCaptor<Event> events = ArgumentCaptor.forClass(Event.class); verify(accessor, times(2)).append(events.capture()); Event event1 = events.getAllValues().get(0); Event event2 = events.getAllValues().get(1); assertThat(event1.getObjectId()).isEqualTo("id1"); assertThat(event1.getOperation()).isEqualTo("ADD"); assertThat(event1.getData()).isEqualTo("{\"param\":\"value1\"}"); assertThat(event2.getObjectId()).isEqualTo("id2"); assertThat(event2.getOperation()).isEqualTo("ADD"); assertThat(event2.getData()).isEqualTo("{\"param\":\"value2\"}"); }
@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);  }