-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Steffen Hildebrandt
committed
Aug 30, 2016
1 parent
9908144
commit 91b71d9
Showing
3 changed files
with
144 additions
and
0 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
71 changes: 71 additions & 0 deletions
71
src/main/java/org/eluder/coveralls/maven/plugin/service/Wercker.java
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.eluder.coveralls.maven.plugin.service; | ||
|
||
import java.util.Map; | ||
|
||
/* | ||
* #[license] | ||
* coveralls-maven-plugin | ||
* %% | ||
* Copyright (C) 2013 - 2016 Tapio Rautonen | ||
* %% | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* %[license] | ||
*/ | ||
|
||
/** | ||
* Service implementation for Wercker CI. | ||
* <p> | ||
* http://wercker.com/ | ||
*/ | ||
public class Wercker extends AbstractServiceSetup { | ||
|
||
public static final String WERCKER_NAME = "wercker"; | ||
public static final String WERCKER_BUILD_URL = "WERCKER_RUN_URL"; | ||
public static final String WERCKER_BRANCH = "WERCKER_GIT_BRANCH"; | ||
|
||
public Wercker(final Map<String, String> env) { | ||
super(env); | ||
} | ||
|
||
@Override | ||
public boolean isSelected() { | ||
return getProperty(WERCKER_BRANCH) != null; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return WERCKER_NAME; | ||
} | ||
|
||
@Override | ||
public String getJobId() { | ||
final String buildUrl = getBuildUrl(); | ||
return buildUrl.substring(buildUrl.lastIndexOf("/") + 1); | ||
} | ||
|
||
@Override | ||
public String getBuildUrl() { | ||
return getProperty(WERCKER_BUILD_URL); | ||
} | ||
|
||
@Override | ||
public String getBranch() { | ||
return getProperty(WERCKER_BRANCH); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
src/test/java/org/eluder/coveralls/maven/plugin/service/WerckerTest.java
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package org.eluder.coveralls.maven.plugin.service; | ||
|
||
/* | ||
* #[license] | ||
* coveralls-maven-plugin | ||
* %% | ||
* Copyright (C) 2013 - 2016 Tapio Rautonen | ||
* %% | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* %[license] | ||
*/ | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class WerckerTest { | ||
|
||
private Map<String, String> env() { | ||
Map<String, String> env = new HashMap<String, String>(); | ||
env.put("WERCKER_RUN_URL", "https://app.wercker.com/build/123456789"); | ||
env.put("WERCKER_GIT_BRANCH", "master"); | ||
return env; | ||
} | ||
|
||
@Test | ||
public void testIsSelectedForNothing() { | ||
assertFalse(new Wercker(new HashMap<String, String>()).isSelected()); | ||
} | ||
|
||
@Test | ||
public void testIsSelectedForTravis() { | ||
assertTrue(new Wercker(env()).isSelected()); | ||
} | ||
|
||
@Test | ||
public void testGetName() { | ||
assertEquals("wercker", new Wercker(env()).getName()); | ||
} | ||
|
||
@Test | ||
public void testGetJobId() { | ||
assertEquals("123456789", new Wercker(env()).getJobId()); | ||
} | ||
|
||
@Test | ||
public void testGetBranch() { | ||
assertEquals("master", new Wercker(env()).getBranch()); | ||
} | ||
} |