-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a subset of default notification events (#1)
Only use broken, failed, and fixed by default. This default can be changed in the plugin config.
- Loading branch information
Sandro Heinzelmann
committed
Apr 27, 2018
1 parent
dcf234b
commit 6fb9c82
Showing
6 changed files
with
70 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,10 @@ | |
@RunWith(MockitoJUnitRunner.class) | ||
public class ConfigurableNotificationListenerTest { | ||
|
||
private static final Set<String> DEFAULT_EVENTS = new HashSet<>(Arrays.asList( | ||
"broken", "fixed", "failed" | ||
)); | ||
|
||
private static final List<BiConsumer<ConfigurableNotificationListener, StageStateChange>> ALL_HANDLERS = Arrays.asList( | ||
ConfigurableNotificationListener::handleBroken, | ||
ConfigurableNotificationListener::handlePassed, | ||
|
@@ -54,29 +58,29 @@ public void shouldRouteToSingleTarget() throws Exception { | |
addMockEnvVariables("pipeline1", | ||
"GONG_TEST_TARGET", "[email protected]"); | ||
|
||
listener.handlePassed(new StageStateChange("pipeline1", | ||
listener.handleBroken(new StageStateChange("pipeline1", | ||
10, | ||
"stage1", | ||
"passed")); | ||
"broken")); | ||
|
||
listener.assertTargets("passed", "[email protected]"); | ||
listener.assertTargets("broken", "[email protected]"); | ||
} | ||
|
||
@Test | ||
public void shouldRouteToMultipleTargetsInSameVar() throws Exception { | ||
addMockEnvVariables("pipeline1", | ||
"GONG_TEST_TARGET", "[email protected], [email protected]"); | ||
|
||
listener.handlePassed(new StageStateChange("pipeline1", | ||
listener.handleBroken(new StageStateChange("pipeline1", | ||
10, | ||
"stage1", | ||
"passed")); | ||
"broken")); | ||
|
||
listener.assertTargets("passed", "[email protected]", "[email protected]"); | ||
listener.assertTargets("broken", "[email protected]", "[email protected]"); | ||
} | ||
|
||
@Test | ||
public void shouldRouteAllEventsToSingleTarget() throws Exception { | ||
public void shouldRouteAllDefaultEventsToSingleTarget() throws Exception { | ||
addMockEnvVariables("pipeline1", | ||
"GONG_TEST_TARGET", "[email protected]"); | ||
|
||
|
@@ -86,13 +90,10 @@ public void shouldRouteAllEventsToSingleTarget() throws Exception { | |
"dummy"); | ||
ALL_HANDLERS.forEach(h -> h.accept(listener, change)); | ||
|
||
assertEquals(6, listener.targets.size()); | ||
listener.assertTargets("broken", "[email protected]"); | ||
listener.assertTargets("passed", "[email protected]"); | ||
assertEquals(3, listener.targets.size()); | ||
listener.assertTargets("fixed", "[email protected]"); | ||
listener.assertTargets("broken", "[email protected]"); | ||
listener.assertTargets("failed", "[email protected]"); | ||
listener.assertTargets("cancelled", "[email protected]"); | ||
listener.assertTargets("building", "[email protected]"); | ||
} | ||
|
||
@Test | ||
|
@@ -190,7 +191,7 @@ public void shouldRouteForSpecificStagesAndEvents() throws Exception { | |
} | ||
|
||
@Test | ||
public void shouldRouteForSpecificStagesAndAllEvents() throws Exception { | ||
public void shouldRouteForSpecificStagesAndAllDefaultEvents() throws Exception { | ||
addMockEnvVariables("pipeline1", | ||
"GONG_TEST_TARGET", "[email protected]", | ||
"GONG_TEST_EVENTS", "stage2.broken, stage1.all"); | ||
|
@@ -202,7 +203,10 @@ public void shouldRouteForSpecificStagesAndAllEvents() throws Exception { | |
|
||
ALL_HANDLERS.forEach(h -> h.accept(listener, change1)); | ||
|
||
assertEquals(ALL_HANDLERS.size(), listener.targets.size()); | ||
assertEquals(3, listener.targets.size()); | ||
listener.assertTargetsForStage("stage1", "fixed", "[email protected]"); | ||
listener.assertTargetsForStage("stage1", "broken", "[email protected]"); | ||
listener.assertTargetsForStage("stage1", "failed", "[email protected]"); | ||
} | ||
|
||
@Test | ||
|
@@ -315,7 +319,7 @@ private class Target { | |
|
||
public TestConfigurableNotificationListener(PipelineInfoProvider pipelineInfo, String envVariableBase, | ||
String targetEnvVariableSuffix, String eventsEnvVariableSuffix) { | ||
super(pipelineInfo, envVariableBase, targetEnvVariableSuffix, eventsEnvVariableSuffix); | ||
super(pipelineInfo, envVariableBase, targetEnvVariableSuffix, eventsEnvVariableSuffix, DEFAULT_EVENTS); | ||
} | ||
|
||
@Override | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters