@Test public void write_changed_files() { DefaultInputFile fileWithChangedLines = createInputFile("path1"); DefaultInputFile fileWithoutChangedLines = createInputFile("path2"); Set<Path> paths = new HashSet<>(Arrays.asList(BASE_DIR.resolve("path1"), BASE_DIR.resolve("path2"))); Set<Integer> lines = new HashSet<>(Arrays.asList(1, 10)); when(provider.branchChangedLines(TARGET_BRANCH, BASE_DIR, paths)).thenReturn(Collections.singletonMap(BASE_DIR.resolve("path1"), lines)); when(inputComponentStore.allChangedFilesToPublish()).thenReturn(Arrays.asList(fileWithChangedLines, fileWithoutChangedLines)); publisher.publish(writer); assertPublished(fileWithChangedLines, lines); assertPublished(fileWithoutChangedLines, Collections.emptySet()); }
@Test public void skip_if_scm_is_disabled() { when(scmConfiguration.isDisabled()).thenReturn(true); publisher.publish(writer); verifyZeroInteractions(inputComponentStore, inputModuleHierarchy, provider); assertNotPublished(); }
@Test public void skip_if_target_branch_is_null() { when(branchConfiguration.targetScmBranch()).thenReturn(null); publisher.publish(writer); verifyZeroInteractions(inputComponentStore, inputModuleHierarchy, provider); assertNotPublished(); }
@Test public void skip_if_not_pr_or_slb() { when(branchConfiguration.isShortOrPullRequest()).thenReturn(false); publisher.publish(writer); verifyZeroInteractions(inputComponentStore, inputModuleHierarchy, provider); assertNotPublished(); }
@Test public void skip_if_no_scm_provider() { when(scmConfiguration.provider()).thenReturn(null); publisher.publish(writer); verifyZeroInteractions(inputComponentStore, inputModuleHierarchy, provider); assertNotPublished(); }
@Test public void skip_if_scm_provider_returns_null() { publisher.publish(writer); assertNotPublished(); }