Skip to content

Commit

Permalink
Support for Travis Pro.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnou committed Jul 26, 2018
1 parent 0a4b0e6 commit 7c13e26
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.eluder.coveralls.maven.plugin.service.ServiceSetup;
import org.eluder.coveralls.maven.plugin.service.Shippable;
import org.eluder.coveralls.maven.plugin.service.Travis;
import org.eluder.coveralls.maven.plugin.service.TravisPro;
import org.eluder.coveralls.maven.plugin.service.Wercker;
import org.eluder.coveralls.maven.plugin.source.SourceCallback;
import org.eluder.coveralls.maven.plugin.source.SourceLoader;
Expand Down Expand Up @@ -304,6 +305,7 @@ protected List<ServiceSetup> getServices() {
List<ServiceSetup> services = new ArrayList<>();
services.add(new Shippable(env));
services.add(new Travis(env));
services.add(new TravisPro(env));
services.add(new Circle(env));
services.add(new Jenkins(env));
services.add(new Bamboo(env));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.eluder.coveralls.maven.plugin.service;

import java.util.Map;
import java.util.Properties;

/*
* #[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 Travis CI Pro.
* <p>
* https://travis-ci.org/
*/
public class TravisPro extends Travis {

public static final String TRAVIS_NAME = "travis-pro";

public TravisPro(final Map<String, String> env) {
super(env);
}

@Override
public String getName() {
return TRAVIS_NAME;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
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 java.util.Properties;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class TravisProTest {

private Map<String, String> env() {
Map<String, String> env = new HashMap<String, String>();
env.put("TRAVIS", "true");
env.put("TRAVIS_JOB_ID", "job123");
env.put("TRAVIS_BRANCH", "master");
env.put("TRAVIS_PULL_REQUEST", "pull10");
return env;
}

@Test
public void testIsSelectedForNothing() {
assertFalse(new TravisPro(new HashMap<String, String>()).isSelected());
}

@Test
public void testIsSelectedForTravis() {
assertTrue(new TravisPro(env()).isSelected());
}

@Test
public void testGetName() {
assertEquals("travis-pro", new TravisPro(env()).getName());
}

@Test
public void testGetJobId() {
assertEquals("job123", new TravisPro(env()).getJobId());
}

@Test
public void testGetBranch() {
assertEquals("master", new TravisPro(env()).getBranch());
}

@Test
public void testGetPullRequest() {
assertEquals("pull10", new TravisPro(env()).getPullRequest());
}

@Test
public void testGetEnvironment() {
Properties properties = new TravisPro(env()).getEnvironment();
assertEquals(2, properties.size());
assertEquals("job123", properties.getProperty("travis_job_id"));
assertEquals("pull10", properties.getProperty("travis_pull_request"));
}
}

0 comments on commit 7c13e26

Please sign in to comment.