From 1fbe467baf23f714e7a455a1ab8159e39041da9b Mon Sep 17 00:00:00 2001 From: Anatoly Cherkasov Date: Tue, 28 May 2019 12:19:01 +0300 Subject: [PATCH] BJ-443: bump java, add dr2 (#15) * BJ-443: bump java, add dr2 --- Jenkinsfile | 51 ++++-------------- build_utils | 2 +- pom.xml | 52 +++++++++++++------ .../mpi/ProxyMocketBankMpiApplication.java | 2 +- .../mpi/controller/MpiController.java | 22 ++++---- .../proxy/mocketbank/mpi/utils/MpiAction.java | 13 ++--- .../proxy/mocketbank/mpi/utils/MpiUtils.java | 2 +- .../mpi/utils/constant/MpiCavvAlgorithm.java | 8 +-- .../utils/constant/MpiEnrollmentStatus.java | 6 +-- .../utils/constant/MpiTransactionStatus.java | 8 +-- src/main/resources/application.yml | 8 +-- 11 files changed, 79 insertions(+), 95 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e10e330..09e8e4e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,47 +1,18 @@ #!groovy build('proxy-mocketbank-mpi', 'java-maven') { checkoutRepo() + loadBuildUtils() + + def javaServicePipeline + runStage('load JavaService pipeline') { + javaServicePipeline = load("build_utils/jenkins_lib/pipeJavaService.groovy") + } def serviceName = env.REPO_NAME def mvnArgs = '-DjvmArgs="-Xmx256m"' + def useJava11 = true + def registry = 'dr2.rbkmoney.com' + def registryCredsId = 'jenkins_harbor' - // Run mvn and generate docker file - runStage('Maven package') { - withCredentials([[$class: 'FileBinding', credentialsId: 'java-maven-settings.xml', variable: 'SETTINGS_XML']]) { - def mvn_command_arguments = ' --batch-mode --settings $SETTINGS_XML -P ci ' + - " -Dgit.branch=${env.BRANCH_NAME} " + - " ${mvnArgs}" - if (env.BRANCH_NAME == 'master') { - sh 'mvn deploy' + mvn_command_arguments - } else { - sh 'mvn package' + mvn_command_arguments - } - } - } - - def serviceImage; - def imgShortName = 'rbkmoney/' + "${serviceName}" + ':' + '$COMMIT_ID'; - getCommitId() - runStage('Build Service image') { - serviceImage = docker.build(imgShortName, '-f ./target/Dockerfile ./target') - } - - try { - if (env.BRANCH_NAME == 'master') { - runStage('Push Service image') { - docker.withRegistry('https://dr.rbkmoney.com/v2/', 'dockerhub-rbkmoneycibot') { - serviceImage.push(); - } - // Push under 'withRegistry' generates 2d record with 'long name' in local docker registry. - // Untag the long-name - sh "docker rmi dr.rbkmoney.com/${imgShortName}" - } - } - } - finally { - runStage('Remove local image') { - // Remove the image to keep Jenkins runner clean. - sh "docker rmi ${imgShortName}" - } - } -} + javaServicePipeline(serviceName, useJava11, mvnArgs, registry, registryCredsId) +} \ No newline at end of file diff --git a/build_utils b/build_utils index 0a57c5f..ea4aa04 160000 --- a/build_utils +++ b/build_utils @@ -1 +1 @@ -Subproject commit 0a57c5f10795d77ecf121d509fde7c654175c3c1 +Subproject commit ea4aa042f482551d624fd49a570d28488f479e93 diff --git a/pom.xml b/pom.xml index 504995f..fad0f25 100644 --- a/pom.xml +++ b/pom.xml @@ -7,12 +7,12 @@ com.rbkmoney spring-boot-starter-parent - 1.5.1.RELEASE + 2.1.1.RELEASE proxy-mocketbank-mpi - 1.0.5-SNAPSHOT + 1.0.6-SNAPSHOT jar proxy-mocketbank-mpi @@ -20,10 +20,13 @@ 8080 + ${server.port} UTF-8 Anatoly Cherkasov <a.cherkasov@rbkmoney.com> - 22c57470c4fc47161894f036b7cf9d70f42b75f5 - 0.2.1 + c0d0900ec19c907d866f8360031a836049985110 + dr2.rbkmoney.com + 0.3.6 + ${project.basedir}/../target/jacoco.exec @@ -36,6 +39,11 @@ org.springframework.boot spring-boot-starter-actuator + + com.rbkmoney + spring-boot-starter-metrics-statsd + 1.1.0 + org.springframework.boot spring-boot-starter-jetty @@ -47,7 +55,12 @@ net.logstash.logback logstash-logback-encoder - 4.6 + 5.2 + + + org.projectlombok + lombok + 1.18.4 @@ -61,18 +74,6 @@ ${shared.resources.version} - - junit - junit - 4.12 - test - - - org.mockito - mockito-all - 1.10.19 - test - org.springframework.boot spring-boot-starter-test @@ -134,6 +135,23 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.2 + + ${sonar.jacoco.reportPath} + true + + + + agent + + prepare-agent + + + + diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/ProxyMocketBankMpiApplication.java b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/ProxyMocketBankMpiApplication.java index f95c5ee..b8a3cb2 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/ProxyMocketBankMpiApplication.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/ProxyMocketBankMpiApplication.java @@ -7,7 +7,7 @@ import org.springframework.boot.web.servlet.ServletComponentScan; @ServletComponentScan @SpringBootApplication(scanBasePackages = {"com.rbkmoney.proxy.mocketbank.mpi"}) public class ProxyMocketBankMpiApplication { - public static void main(String[] args) throws Exception { + public static void main(String[] args) { SpringApplication.run(ProxyMocketBankMpiApplication.class, args); } } diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/controller/MpiController.java b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/controller/MpiController.java index 6da11e5..d94d0da 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/controller/MpiController.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/controller/MpiController.java @@ -8,8 +8,7 @@ import com.rbkmoney.proxy.mocketbank.mpi.utils.MpiUtils; import com.rbkmoney.proxy.mocketbank.mpi.utils.constant.MpiCavvAlgorithm; import com.rbkmoney.proxy.mocketbank.mpi.utils.constant.MpiEnrollmentStatus; import com.rbkmoney.proxy.mocketbank.mpi.utils.constant.MpiTransactionStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import org.springframework.web.bind.annotation.RequestMapping; @@ -24,13 +23,12 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +@Slf4j @RestController @RequestMapping(value = "/mpi") public class MpiController { - private final static Logger LOGGER = LoggerFactory.getLogger(MpiController.class); - - public final static String DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + private static final String DATETIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"; @Value("${fixture.cards}") private Resource fixtureCards; @@ -51,7 +49,7 @@ public class MpiController { @RequestParam(value = "year", required = true) String year, @RequestParam(value = "month", required = true) String month ) throws IOException { - LOGGER.info("VerifyEnrollment input params: pan {}, year {}, month {}", + log.info("VerifyEnrollment input params: pan {}, year {}, month {}", MpiUtils.maskNumber(pan), year, month ); @@ -68,7 +66,7 @@ public class MpiController { } String response = new ObjectMapper().writeValueAsString(map); - LOGGER.info("VerifyEnrollment response {}", response); + log.info("VerifyEnrollment response {}", response); return response; } @@ -79,7 +77,7 @@ public class MpiController { @RequestParam(value = "paRes", required = true) String paRes ) throws IOException { - LOGGER.info("ValidatePaRes input params: pan {}, paRes {}", MpiUtils.maskNumber(pan), paRes); + log.info("ValidatePaRes input params: pan {}, paRes {}", MpiUtils.maskNumber(pan), paRes); CardUtils cardUtils = new CardUtils(cardList); Optional card = cardUtils.getCardByPan(pan); @@ -107,8 +105,7 @@ public class MpiController { } String response = new ObjectMapper().writeValueAsString(map); - LOGGER.info("ValidatePaRes response {}", response); - + log.info("ValidatePaRes response {}", response); return response; } @@ -118,15 +115,14 @@ public class MpiController { @RequestParam(value = "MD", required = true) String md, @RequestParam(value = "TermUrl", required = true) String termUrl ) { - LOGGER.info("Form ACS input params: paReq {}, MD {}, TermUrl {}", paReq, md, termUrl); + log.info("Form ACS input params: paReq {}, MD {}, TermUrl {}", paReq, md, termUrl); ModelAndView model = new ModelAndView(); model.setViewName("acs_form"); model.addObject("action", termUrl); model.addObject("pan", "XXXX XXXX XXXX XXXX"); model.addObject("PaRes", "PaRes"); model.addObject("MD", md); - LOGGER.info("Form ACS show the form"); - + log.info("Form ACS show the form"); return model; } diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/MpiAction.java b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/MpiAction.java index e5310a3..4b4f1fc 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/MpiAction.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/MpiAction.java @@ -1,8 +1,13 @@ package com.rbkmoney.proxy.mocketbank.mpi.utils; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + import java.util.Arrays; +@Getter +@RequiredArgsConstructor public enum MpiAction { UNKNOWN("Unknown"), @@ -18,14 +23,6 @@ public enum MpiAction { private final String action; - MpiAction(String action) { - this.action = action; - } - - public String getAction() { - return action; - } - public static MpiAction findByValue(String value) { return Arrays.stream(values()).filter((action) -> action.getAction().equals(value)) .findFirst() diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/MpiUtils.java b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/MpiUtils.java index cb7617b..c94c785 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/MpiUtils.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/MpiUtils.java @@ -5,7 +5,7 @@ import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils; public class MpiUtils { - public final static String MASK_CHAR = "*"; + public static final String MASK_CHAR = "*"; public static String maskNumber(final String creditCardNumber, int startLength, int endLength, String maskChar) { final String cardNumber = creditCardNumber.replaceAll("\\D", ""); diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiCavvAlgorithm.java b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiCavvAlgorithm.java index 29767d7..27672b4 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiCavvAlgorithm.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiCavvAlgorithm.java @@ -8,21 +8,21 @@ public class MpiCavvAlgorithm { /** * 0: HMAC (as per SET TransStain) (no longer in use for version 1.0.2) */ - public final static String HMAC_AS_PER_SET_TRANS_STAIN = "0"; + public static final String HMAC_AS_PER_SET_TRANS_STAIN = "0"; /** * 1: CVV (no longer in use for version 1.0.2). */ - public final static String CVV_NO_LONGER = "1"; + public static final String CVV_NO_LONGER = "1"; /** * 2: CVV with ATN. */ - public final static String CVV_WITH_ATN = "2"; + public static final String CVV_WITH_ATN = "2"; /** * 3: MasterCard SPA algorithm. */ - public final static String MASTERCARD_SPA_ALGORITHM = "3"; + public static final String MASTERCARD_SPA_ALGORITHM = "3"; } diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiEnrollmentStatus.java b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiEnrollmentStatus.java index d628daa..3cbca45 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiEnrollmentStatus.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiEnrollmentStatus.java @@ -10,17 +10,17 @@ public class MpiEnrollmentStatus { * supported, or proof of attempted authentication available. The merchant uses the * URL of issuer ACS included in VERes to create the Payer Authentication Request. */ - public final static String AUTHENTICATION_AVAILABLE = "Y"; + public static final String AUTHENTICATION_AVAILABLE = "Y"; /** * Cardholder Not Participating – Cardholder is not enrolled. */ - public final static String CARDHOLDER_NOT_PARTICIPATING = "N"; + public static final String CARDHOLDER_NOT_PARTICIPATING = "N"; /** * Unable to Authenticate or Card Not Eligible for Attempts * (such as a Commercial or anonymous Prepaid card). */ - public final static String UNABLE_TO_AUTHENTICATE = "U"; + public static final String UNABLE_TO_AUTHENTICATE = "U"; } diff --git a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiTransactionStatus.java b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiTransactionStatus.java index 0121dc8..951c7fa 100644 --- a/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiTransactionStatus.java +++ b/src/main/java/com/rbkmoney/proxy/mocketbank/mpi/utils/constant/MpiTransactionStatus.java @@ -9,24 +9,24 @@ public class MpiTransactionStatus { * The merchant submits an authorization request including the * ECI and CAVV supplied in the PARes. */ - public final static String AUTHENTICATION_SUCCESSFUL = "Y"; + public static final String AUTHENTICATION_SUCCESSFUL = "Y"; /** * The merchant must not submit a failed authentication for * authorization. */ - public final static String AUTHENTICATION_FAILED = "N"; + public static final String AUTHENTICATION_FAILED = "N"; /** * The merchant may process an authorization request using the * appropriate ECI. */ - public final static String AUTHENTICATION_COULD_NOT_BE_PERFORMED = "U"; + public static final String AUTHENTICATION_COULD_NOT_BE_PERFORMED = "U"; /** * The merchant submits an authorization request including the * ECI and CAVV supplied in the PARes. */ - public final static String ATTEMPTS_PROCESSING_PERFORMED = "A"; + public static final String ATTEMPTS_PROCESSING_PERFORMED = "A"; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 072922c..4c8a7ce 100755 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -8,9 +8,11 @@ info: responsible: Anatoly Cherkasov stage: dev --- -endpoints: - health: - sensitive: false +management: + metrics: + export: + statsd: + flavor: etsy --- server: port: @server.port@