Skip to content

Commit

Permalink
Merge pull request #77 from paypal/develop
Browse files Browse the repository at this point in the history
Releasing 2.2.0
  • Loading branch information
fabiocarvalho777 authored Jan 3, 2018
2 parents 52cb6c4 + 6ee44ee commit d9423a4
Show file tree
Hide file tree
Showing 431 changed files with 81,764 additions and 1,201 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ branches:
only:
- develop

install: mvn install
before_install:
# Importing key used to sign jars, necessary for release artifacts deployment in Maven Central
- openssl aes-256-cbc -K $encrypted_dd05710e44e2_key -iv $encrypted_dd05710e44e2_iv -in secring.gpg.enc -out secring.gpg -d
- gpg --import secring.gpg

install:
# Building and deploying artifacts to Maven Central
- mvn -B -s settings.xml deploy -Possrh

after_success:
# Installing Codacy code coverage reporter upload tool
Expand All @@ -22,5 +29,3 @@ after_success:
- java -cp ccr.jar com.codacy.CodacyCoverageReporter -l Java -r ./butterfly-metrics-couchdb/target/site/cobertura/coverage.xml --projectToken $CODACY_PROJECT_TOKEN
- java -cp ccr.jar com.codacy.CodacyCoverageReporter -l Java -r ./butterfly-metrics-file/target/site/cobertura/coverage.xml --projectToken $CODACY_PROJECT_TOKEN
- java -cp ccr.jar com.codacy.CodacyCoverageReporter -l Java -r ./butterfly-utilities/target/site/cobertura/coverage.xml --projectToken $CODACY_PROJECT_TOKEN
# Deploying artifacts to Maven Central
- mvn -B -s settings.xml -DskipTests=true -Dcobertura.skip deploy -Possrh
2 changes: 1 addition & 1 deletion butterfly-cli-package/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.paypal.butterfly</groupId>
<artifactId>butterfly-parent</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion butterfly-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.paypal.butterfly</groupId>
<artifactId>butterfly-parent</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ButterflyCliApp extends ButterflyCliOption {

private static Logger logger;

@SuppressWarnings("PMD.DoNotCallSystemExit")
public static void main(String... arguments) throws IOException {
setButterflyHome();
setEnvironment(arguments);
Expand Down Expand Up @@ -59,6 +60,7 @@ private static void setButterflyHome() {
butterflyHome = new File(butterflyHomePath);
}

@SuppressWarnings("PMD.DoNotCallSystemExit")
private static void setEnvironment(String[] arguments) {
if(arguments.length != 0){
try {
Expand Down Expand Up @@ -108,6 +110,8 @@ public static File getButterflyHome() {
return butterflyHome;
}

// This method's visibility is intentionally being set to package
@SuppressWarnings("PMD.DefaultPackage")
static String getBanner() {
return banner;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public ButterflyCliRun run() throws IOException {
}

if (optionSet.has(CLI_OPTION_VERBOSE)) {
logConfigurator.verboseMode(true);
logConfigurator.setVerboseMode(true);
logger.info("Verbose mode is ON");
}

if (optionSet.has(CLI_OPTION_DEBUG)) {
logConfigurator.debugMode(true);
logConfigurator.setDebugMode(true);
logger.info("Debug mode is ON");
logger.info("Butterfly home: {}", ButterflyCliApp.getButterflyHome());
logger.info("JAVA_HOME: {}", System.getenv("JAVA_HOME"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* SLF4J implementation, but the API doesn't allow
* changing the log level in runtime, so here we
* are doing it behind the scenes.
* </br>
* <br>
* At least we are providing this interface
* to isolate these concerns, which will make it
* easier to maintain this code if we ever replace
Expand All @@ -19,24 +19,24 @@
*/
public abstract class LogConfigurator {

LogConfigurator() {
public LogConfigurator() {
setLoggerLevel("com.paypal.butterfly", Level.INFO);
}

public abstract void setLoggerLevel(String logger, Level level);

abstract void setLoggerLevel(Class logger, Level level);
public abstract void setLoggerLevel(Class logger, Level level);

public void debugMode(boolean on) {
public void setDebugMode(boolean on) {
if(on) {
setLoggerLevel("com.paypal.butterfly", Level.DEBUG);
} else {
setLoggerLevel("com.paypal.butterfly", Level.INFO);
}
}

public abstract void verboseMode(boolean on);
public abstract void setVerboseMode(boolean on);

public abstract void logToFile(boolean on);
public abstract void setLogToFile(boolean on);

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,42 @@ public String getPropertyValue() {
}

@Override
public void setContext(Context context) {}
public void setContext(Context context) {
// Nothing to be done here
}
@Override
public Context getContext() {
// Nothing to be done here
return null;
}
@Override
public void addStatus(Status status) {}
public void addStatus(Status status) {
// Nothing to be done here
}
@Override
public void addInfo(String s) {}
public void addInfo(String s) {
// Nothing to be done here
}
@Override
public void addInfo(String s, Throwable throwable) {}
public void addInfo(String s, Throwable throwable) {
// Nothing to be done here
}
@Override
public void addWarn(String s) {}
public void addWarn(String s) {
// Nothing to be done here
}
@Override
public void addWarn(String s, Throwable throwable) {}
public void addWarn(String s, Throwable throwable) {
// Nothing to be done here
}

@Override
public void addError(String s) {}
public void addError(String s) {
// Nothing to be done here
}
@Override
public void addError(String s, Throwable throwable) {}
public void addError(String s, Throwable throwable) {
// Nothing to be done here
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void setLoggerLevel(String logger, org.slf4j.event.Level level) {
}

@Override
void setLoggerLevel(Class logger, org.slf4j.event.Level level) {
public void setLoggerLevel(Class logger, org.slf4j.event.Level level) {
if(level == null) {
throw new IllegalArgumentException("level argument cannot be null");
}
Expand All @@ -46,7 +46,7 @@ private Level getLogbackLogLevel(org.slf4j.event.Level slf4jLevel) {
}

@Override
public void verboseMode(boolean on) {
public void setVerboseMode(boolean on) {
PatternLayoutEncoder patternLayoutEncoder = new PatternLayoutEncoder();
patternLayoutEncoder.setPattern("[%d{HH:mm:ss.SSS}] [%highlight(%level)] %msg%n");
patternLayoutEncoder.setContext(loggerContext);
Expand All @@ -62,7 +62,7 @@ public void verboseMode(boolean on) {
}

@Override
public void logToFile(boolean on) {
public void setLogToFile(boolean on) {
loggerContext.getLogger("ROOT").detachAppender("FILE");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.paypal.butterfly.cli;

import com.test.SampleExtension;
import com.test.SampleTransformationTemplate;
import com.paypal.butterfly.cli.logging.LogConfigurator;
import com.paypal.butterfly.extensions.api.exception.ButterflyException;
import com.paypal.butterfly.extensions.api.upgrade.UpgradePath;
import com.paypal.butterfly.facade.ButterflyFacade;
import com.paypal.butterfly.facade.Configuration;
import com.paypal.butterfly.facade.TransformationResult;
import com.test.SampleExtension;
import com.test.SampleTransformationTemplate;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.modules.testng.PowerMockTestCase;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
Expand All @@ -34,25 +33,29 @@ public class ButterflyCliTest extends PowerMockTestCase {
@Mock
private ButterflyFacade facade;

// Even though this variable is not used explicitly in this class,
// it is necessary to its proper execution, since the mock initialization
// is happening regardless of it
@SuppressWarnings("PMD.UnusedPrivateField")
@Mock
private LogConfigurator logConfigurator;

private File sampleAppFolder;

@BeforeMethod
public void beforeTest() throws ButterflyException {
TransformationResult mockResult = Mockito.mock(TransformationResult.class);
TransformationResult mockResult = mock(TransformationResult.class);

Mockito.when(facade.transform(Mockito.any(File.class), Mockito.any(String.class))).thenReturn(mockResult);
Mockito.when(facade.transform(Mockito.any(File.class), Mockito.any(String.class), Mockito.any(Configuration.class))).thenReturn(mockResult);
Mockito.when(facade.transform(Mockito.any(File.class), Mockito.any(Class.class))).thenReturn(mockResult);
Mockito.when(facade.transform(Mockito.any(File.class), Mockito.any(Class.class), Mockito.any(Configuration.class))).thenReturn(mockResult);
Mockito.when(facade.transform(Mockito.any(File.class), Mockito.any(UpgradePath.class))).thenReturn(mockResult);
Mockito.when(facade.transform(Mockito.any(File.class), Mockito.any(UpgradePath.class), Mockito.any(Configuration.class))).thenReturn(mockResult);
when(facade.transform(any(File.class), any(String.class))).thenReturn(mockResult);
when(facade.transform(any(File.class), any(String.class), any(Configuration.class))).thenReturn(mockResult);
when(facade.transform(any(File.class), any(Class.class))).thenReturn(mockResult);
when(facade.transform(any(File.class), any(Class.class), any(Configuration.class))).thenReturn(mockResult);
when(facade.transform(any(File.class), any(UpgradePath.class))).thenReturn(mockResult);
when(facade.transform(any(File.class), any(UpgradePath.class), any(Configuration.class))).thenReturn(mockResult);

File file = new File("");
Mockito.when(mockResult.getTransformedApplicationLocation()).thenReturn(file);
Mockito.when(mockResult.getManualInstructionsFile()).thenReturn(file);
when(mockResult.getTransformedApplicationLocation()).thenReturn(file);
when(mockResult.getManualInstructionsFile()).thenReturn(file);

sampleAppFolder = new File(this.getClass().getResource("/sample_app").getFile());
}
Expand All @@ -69,7 +72,7 @@ public void testListingExtensions() throws IOException {

String[] arguments = {"-l", "-v"};
butterflyCli.setOptionSet(arguments);

int status = butterflyCli.run().getExitStatus();

Assert.assertEquals(status, 0);
Expand Down Expand Up @@ -100,7 +103,7 @@ public void testTransformation() throws IOException, ButterflyException {
*/
@Test
public void testTransformationWithShortcut() throws IOException, ButterflyException {
Mockito.when(facade.getRegisteredExtension()).thenReturn(new SampleExtension());
when(facade.getRegisteredExtension()).thenReturn(new SampleExtension());

String arguments[] = {sampleAppFolder.getAbsolutePath(), "-s", "2"};
butterflyCli.setOptionSet(arguments);
Expand All @@ -119,7 +122,7 @@ public void testTransformationWithShortcut() throws IOException, ButterflyExcept
*/
@Test
public void testTransformationWithShortcutButIgnoringIt() throws IOException, ButterflyException {
Mockito.when(facade.getRegisteredExtension()).thenReturn(new SampleExtension());
when(facade.getRegisteredExtension()).thenReturn(new SampleExtension());

String arguments[] = {sampleAppFolder.getAbsolutePath(), "-t", "com.test.SampleTransformationTemplate", "-z", "-s", "2"};
butterflyCli.setOptionSet(arguments);
Expand Down Expand Up @@ -173,7 +176,7 @@ public void testTransformationWithValidOutPutDir() throws IOException, Butterfly

@Test
public void testAutomaticResolution() throws IOException, ButterflyException {
Mockito.doReturn(SampleTransformationTemplate.class).when(facade).automaticResolution(Mockito.any(File.class));
doReturn(SampleTransformationTemplate.class).when(facade).automaticResolution(any(File.class));
String arguments[] = {sampleAppFolder.getAbsolutePath()};
butterflyCli.setOptionSet(arguments);
int status = butterflyCli.run().getExitStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class LogbackLogConfiguratorTest extends PowerMockTestCase {
public void testVerboseOn() {
Assert.assertNotNull(logbackVerboseConfigurator);
Assert.assertNotNull(loggerContext);
logbackVerboseConfigurator.debugMode(true);
logbackVerboseConfigurator.setDebugMode(true);
Assert.assertTrue(loggerContext.getLogger("com.paypal.butterfly").getLevel() == ch.qos.logback.classic.Level.DEBUG);
}

Expand All @@ -35,7 +35,7 @@ public void testVerboseOn() {
public void testVerboseOff() {
Assert.assertNotNull(logbackVerboseConfigurator);
Assert.assertNotNull(loggerContext);
logbackVerboseConfigurator.debugMode(false);
logbackVerboseConfigurator.setDebugMode(false);
Assert.assertTrue(loggerContext.getLogger("com.paypal.butterfly").getLevel() == ch.qos.logback.classic.Level.INFO);
}

Expand Down
2 changes: 1 addition & 1 deletion butterfly-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.paypal.butterfly</groupId>
<artifactId>butterfly-parent</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
<relativePath>..</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
class InternalTransformationException extends TransformationException {

TransformationContextImpl transformationContext;
private TransformationContextImpl transformationContext;

InternalTransformationException(String exceptionMessage, TransformationContextImpl transformationContext) {
super(exceptionMessage);
Expand All @@ -27,6 +27,8 @@ class InternalTransformationException extends TransformationException {
this(e.getMessage(), e, transformationContext);
}

// This method's visibility is intentionally being set to package
@SuppressWarnings("PMD.DefaultPackage")
TransformationContextImpl getTransformationContext() {
return transformationContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* This class processes all {@link com.paypal.butterfly.extensions.api.utilities.ManualInstruction}
* objects present in a {@link TransformationContextImpl] object and persist them in a set of MD files,
* objects present in a {@link TransformationContextImpl} object and persist them in a set of MD files,
* to be placed in the transformed application folder
*
* @author facarvalho
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* @author facarvalho
*/
@SuppressWarnings("PMD.DefaultPackage")
public class TemplateTransformation extends Transformation {

private static final String TO_STRING_SYNTAX = "{ \"application\" : %s, \"template\" : %s, \"templateClass\" : %s }";
Expand Down Expand Up @@ -39,7 +40,7 @@ String getExtensionVersion() {
}

@Override
String getTemplatetName() {
String getTemplateName() {
return template.getName();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* @author facarvalho
*/
@SuppressWarnings("PMD.DefaultPackage")
public abstract class Transformation {

private static final Logger logger = LoggerFactory.getLogger(Transformation.class);
Expand Down Expand Up @@ -73,7 +74,7 @@ File getManualInstructionsDir() {

abstract String getExtensionVersion();

abstract String getTemplatetName();
abstract String getTemplateName();

protected String getExtensionName(Class<? extends Extension> extension) {
return extension.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*
* @author facarvalho
*/
@SuppressWarnings("PMD.DefaultPackage")
@SuppressFBWarnings("URF_UNREAD_FIELD")
class TransformationContextImpl implements TransformationContext {

Expand Down
Loading

0 comments on commit d9423a4

Please sign in to comment.