Skip to content

Commit

Permalink
Use send-notification 0.6
Browse files Browse the repository at this point in the history
Smarter implementation for default notifier.
  • Loading branch information
jcgay committed Jul 14, 2015
1 parent b3b090a commit cab405b
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 40 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ See [CHANGELOG](https://github.com/jcgay/maven-notifier/blob/master/CHANGELOG.md

###Growl

Used by default on OS X [(paid app)](http://growl.info/) and Windows [(free)](http://www.growlforwindows.com/gfw/).
Available for OS X [(paid app)](http://growl.info/) and Windows [(free)](http://www.growlforwindows.com/gfw/).

![Growl success](http://jeanchristophegay.com/images/notifier.growl_.success.png) ![Growl fail](http://jeanchristophegay.com/images/notifier.growl_.fail_.png)

###notify-send

Used by default on linux.
For linux.

![notify-send success](http://jeanchristophegay.com/images/notifier.notify-send.success.png)
![notify-send fail](http://jeanchristophegay.com/images/notifier.notify-send.error_.fail_.png)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>fr.jcgay.send-notification</groupId>
<artifactId>send-notification</artifactId>
<version>0.5</version>
<version>0.6</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public abstract class AbstractCustomEventSpy implements Notifier {
@Override
public final void init(EventSpy.Context context) {
stopwatch.start();
configure();
}

@Override
Expand Down Expand Up @@ -63,8 +62,6 @@ public void setStopwatch(Stopwatch stopwatch) {

protected abstract void fireNotification(MavenExecutionResult event);

protected abstract void configure();

protected Status getBuildStatus(MavenExecutionResult result) {
return result.hasExceptions() ? Status.FAILURE : Status.SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static fr.jcgay.notification.Notifier configureNotifier(SendNotification sendNot
return sendNotification
.setApplication(MAVEN)
.addConfigurationProperties(ConfigurationParser.readProperties())
.chooseNotifier();
.initNotifier();
}

@VisibleForTesting
Expand Down Expand Up @@ -79,11 +79,6 @@ protected void fireNotification(MavenExecutionResult event) {
);
}

@Override
protected void configure() {
notifier.init();
}

@Override
public void onFailWithoutProject(List<Throwable> exceptions) {
super.onFailWithoutProject(exceptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ protected void fireNotification(MavenExecutionResult event) {
playSound(getBuildStatus(event));
}

@Override
protected void configure() {
// do nothing
}

private void playSound(Status status) {
AudioInputStream ais = getAudioStream(status);
if (ais == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ class AbstractCustomEventSpyTest {
protected void fireNotification(MavenExecutionResult event) {

}

@Override
protected void configure() {

}
}
stopwatch = new Stopwatch(new KnownElapsedTimeTicker(SECONDS.toNanos(2L)))
eventSpy.stopwatch = stopwatch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,5 @@ class AbstractCustomEventSpyThresholdTest {
protected void fireNotification(MavenExecutionResult event) {
notifier.send()
}

@Override
protected void configure() {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import fr.jcgay.maven.notifier.Configuration
import fr.jcgay.maven.notifier.ConfigurationParser
import fr.jcgay.notification.*
import groovy.transform.CompileStatic
import org.apache.maven.eventspy.EventSpy
import org.apache.maven.execution.BuildSuccess
import org.apache.maven.execution.MavenExecutionResult
import org.apache.maven.project.MavenProject
Expand Down Expand Up @@ -50,13 +49,6 @@ class SendNotificationNotifierTest {
underTest.configuration = parser
}

@Test
void 'should call init when initializing notifier'() {
underTest.init(aContext())

verify(notifier).init()
}

@Test
void 'should call close when exiting notifier'() {
underTest.close()
Expand Down Expand Up @@ -124,7 +116,7 @@ class SendNotificationNotifierTest {
Icon.create(resource("maven.png"), "maven"))
.build())
verify(sendNotification).addConfigurationProperties(isA(Properties))
verify(sendNotification).chooseNotifier()
verify(sendNotification).initNotifier()
}

@Test
Expand Down Expand Up @@ -204,10 +196,6 @@ class SendNotificationNotifierTest {
result
}

private static EventSpy.Context aContext() {
mock EventSpy.Context
}

private static MavenExecutionResult anEvent(String projectName) {
def result = mock(MavenExecutionResult, RETURNS_DEEP_STUBS)
when result.project.name thenReturn projectName
Expand Down

0 comments on commit cab405b

Please sign in to comment.