public EventComponentChangeDto insertEventComponentChanges(EventDto event, SnapshotDto analysis, ChangeCategory changeCategory, ComponentDto component, @Nullable BranchDto branch) { EventComponentChangeDto eventComponentChange = new EventComponentChangeDto() .setUuid(UuidFactoryFast.getInstance().create()) .setCategory(changeCategory) .setEventUuid(event.getUuid()) .setComponentUuid(component.uuid()) .setComponentKey(component.getKey()) .setComponentName(component.name()) .setComponentBranchKey(Optional.ofNullable(branch).map(BranchDto::getKey).orElse(null)); EventPurgeData eventPurgeData = new EventPurgeData(analysis.getComponentUuid(), analysis.getUuid()); dbClient.eventComponentChangeDao().insert(dbSession, eventComponentChange, eventPurgeData); db.commit(); return eventComponentChange; }
.setComponentBranchKey(null)) .toArray(EventComponentChangeDto[]::new); EventPurgeData doesNotMatter = new EventPurgeData(randomAlphabetic(7), randomAlphabetic(8)); long now = random.nextLong(); when(system2.now()).thenReturn(now) Arrays.stream(event2Dtos).forEach(dto -> underTest.insert(dbSession, dto, doesNotMatter)); assertThat(underTest.selectByAnalysisUuids(dbSession, singletonList(doesNotMatter.getAnalysisUuid()))) .extracting( EventComponentChangeDto::getUuid,
@Test public void selectByEventUuid_branchKey_can_be_null() { String eventBase = randomAlphabetic(5); String rowBase = randomAlphabetic(6); String eventUuid = eventBase + "_event_uuid"; EventComponentChangeDto dto = new EventComponentChangeDto() .setCategory(randomChangeCategory()) .setUuid(rowBase + "_uuid") .setEventUuid(eventUuid) .setComponentUuid(rowBase + "_component_uuid") .setComponentKey(rowBase + "_component_key") .setComponentName(rowBase + "_component_name") .setComponentBranchKey(null); EventPurgeData purgeData = new EventPurgeData(eventBase + "_component_uuid", eventBase + "_analysis_uuid"); long now = random.nextLong(); when(system2.now()) .thenReturn(now) .thenThrow(new IllegalStateException("now should not be called twice")); underTest.insert(dbSession, dto, purgeData); assertThat(underTest.selectByEventUuid(dbSession, eventUuid)) .extracting(EventComponentChangeDto::getUuid, EventComponentChangeDto::getComponentBranchKey) .containsOnly(tuple(dto.getUuid(), null)); }
private void insertEventComponentChanges(ComponentDto component, SnapshotDto analysis, EventComponentChangeDto... changes) { EventPurgeData eventPurgeData = new EventPurgeData(component.uuid(), analysis.getUuid()); for (EventComponentChangeDto change : changes) { db.getDbClient().eventComponentChangeDao().insert(db.getSession(), change, eventPurgeData); } db.getSession().commit(); }
.setComponentBranchKey(null)) .toArray(EventComponentChangeDto[]::new); EventPurgeData doesNotMatter = new EventPurgeData(randomAlphabetic(7), randomAlphabetic(8)); long now = random.nextLong(); when(system2.now()).thenReturn(now)
.setComponentName(rowBase + "_component_name") .setComponentBranchKey(rowBase + "_component_branch_key"); EventPurgeData purgeData = new EventPurgeData(eventBase + "_component_uuid", eventBase + "_analysis_uuid"); long now = random.nextLong(); when(system2.now()).thenReturn(now);
.setComponentName(rowBase + "_component_name") .setComponentBranchKey(rowBase + "_component_branch_key"); EventPurgeData purgeData = new EventPurgeData(eventBase + "_component_uuid", eventBase + "_analysis_uuid"); long now = random.nextLong(); when(system2.now()).thenReturn(now);