From fa1d1c206b93d45445e90ab3004783f925cfe9a7 Mon Sep 17 00:00:00 2001 From: philippe SIMO Date: Fri, 20 Aug 2021 01:46:23 +0200 Subject: [PATCH 01/26] Selenium --- pom.xml | 10 +++ src/main/resources/templates/calculator.html | 8 +- .../e2e/MultiplicationJourneyE2ETest.java | 73 +++++++++++++++++++ 3 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java diff --git a/pom.xml b/pom.xml index 0c27268..6aa21e1 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,16 @@ javax.inject 1 + + org.seleniumhq.selenium + selenium-java + test + + + io.github.bonigarcia + webdrivermanager + 3.7.1 + calculator diff --git a/src/main/resources/templates/calculator.html b/src/main/resources/templates/calculator.html index 9174951..277575c 100644 --- a/src/main/resources/templates/calculator.html +++ b/src/main/resources/templates/calculator.html @@ -28,10 +28,10 @@

- +
- @@ -39,12 +39,12 @@

- +
- +
diff --git a/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java b/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java new file mode 100644 index 0000000..aff1351 --- /dev/null +++ b/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java @@ -0,0 +1,73 @@ +package tech.zerofiltre.testing.calcul.e2e; + +import static org.assertj.core.api.Assertions.assertThat; + +import io.github.bonigarcia.wdm.WebDriverManager; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class MultiplicationJourneyE2ETest { + + @LocalServerPort + private int port; + + private WebDriver webDriver; + private String baseUrl; + + @BeforeAll + static void setUpFireFoxDriver() { + WebDriverManager.firefoxdriver().setup(); + } + + @BeforeEach + void setUpWebDriver() { + webDriver = new FirefoxDriver(); + baseUrl = "http://localhost:" + port + "/calculator"; + + } + + @AfterEach + void quitWebDriver() { + if (webDriver != null) { + webDriver.quit(); + } + } + + @Test + void multiplyTwoBySixteenMustReturn32(){ + + //GIVEN + webDriver.get(baseUrl); + WebElement leftField = webDriver.findElement(By.id("left")); + WebElement typeDropDown = webDriver.findElement(By.id("type")); + WebElement rightField = webDriver.findElement(By.id("right")); + WebElement submitButton = webDriver.findElement(By.id("submit")); + + //WHEN + leftField.sendKeys("2"); + typeDropDown.sendKeys("x"); + rightField.sendKeys("16"); + submitButton.click(); + + //THEN + WebDriverWait waiter = new WebDriverWait(webDriver,5); + WebElement solutionElement = waiter.until(ExpectedConditions.presenceOfElementLocated(By.id("solution"))); + String solution = solutionElement.getText(); + assertThat(solution).isEqualTo("32"); + } + + +} From 4799acc0b2013bd8ac0e9156961a9d44b2b60f80 Mon Sep 17 00:00:00 2001 From: philippe SIMO Date: Fri, 20 Aug 2021 23:17:48 +0200 Subject: [PATCH 02/26] Add specific project maven settings --- .m2/settings.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .m2/settings.xml diff --git a/.m2/settings.xml b/.m2/settings.xml new file mode 100644 index 0000000..510e0ba --- /dev/null +++ b/.m2/settings.xml @@ -0,0 +1,18 @@ + + + org.sonarsource.scanner.maven + + + + sonar + + true + + + + http://localhost:9000 + + + + + \ No newline at end of file From c52fc4f6ee2cffda3f0425edc0b7bf8174054fb3 Mon Sep 17 00:00:00 2001 From: philippe SIMO Date: Fri, 20 Aug 2021 23:44:28 +0200 Subject: [PATCH 03/26] Corect code smells --- .../testing/calcul/domain/Calculator.java | 8 +- .../controller/CalculatorControllerSIT.java | 4 +- .../testing/calcul/domain/CalculatorTest.java | 34 +-- .../domain/ConversionCalculatorTest.java | 10 +- .../calcul/domain/DoubleCalculatorTest.java | 6 +- .../domain/StatisticsCalculatorTest.java | 8 +- .../service/BatchCalculatorServiceTest.java | 12 +- .../calcul/service/CalculatorServiceIT.java | 33 ++- .../calcul/service/CalculatorServiceTest.java | 234 +++++++++--------- .../calcul/service/SolutionFormatterTest.java | 30 +-- 10 files changed, 190 insertions(+), 189 deletions(-) diff --git a/src/main/java/tech/zerofiltre/testing/calcul/domain/Calculator.java b/src/main/java/tech/zerofiltre/testing/calcul/domain/Calculator.java index 6492e44..afe011e 100644 --- a/src/main/java/tech/zerofiltre/testing/calcul/domain/Calculator.java +++ b/src/main/java/tech/zerofiltre/testing/calcul/domain/Calculator.java @@ -4,10 +4,14 @@ import java.util.Set; import javax.inject.Named; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Named public class Calculator { + Logger logger = LoggerFactory.getLogger(Calculator.class); + public int add(int a, int b) { return a + b; } @@ -54,12 +58,12 @@ public void longCalculation() { try { Thread.sleep(500); } catch (final InterruptedException e) { - e.printStackTrace(); + logger.debug("Thread has been interrupted", e); } } public Set digitsSet(int number) { - final Set integers = new HashSet(); + final Set integers = new HashSet<>(); final String numberString = String.valueOf(number); for (int i = 0; i < numberString.length(); i++) { diff --git a/src/test/java/tech/zerofiltre/testing/calcul/controller/CalculatorControllerSIT.java b/src/test/java/tech/zerofiltre/testing/calcul/controller/CalculatorControllerSIT.java index 382bbe7..b81b853 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/controller/CalculatorControllerSIT.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/controller/CalculatorControllerSIT.java @@ -22,7 +22,7 @@ @WebMvcTest(controllers = { CalculatorController.class, CalculatorService.class }) @ExtendWith(SpringExtension.class) -public class CalculatorControllerSIT { +class CalculatorControllerSIT { @Inject private MockMvc mockMvc; @@ -34,7 +34,7 @@ public class CalculatorControllerSIT { private Calculator calculator; @Test - public void givenACalculatorApp_whenRequestToAdd_thenSolutionIsShown() throws Exception { + void givenACalculatorApp_whenRequestToAdd_thenSolutionIsShown() throws Exception { // GIVEN when(calculator.add(2, 3)).thenReturn(5); diff --git a/src/test/java/tech/zerofiltre/testing/calcul/domain/CalculatorTest.java b/src/test/java/tech/zerofiltre/testing/calcul/domain/CalculatorTest.java index 7ef7a90..c72844e 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/domain/CalculatorTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/domain/CalculatorTest.java @@ -27,7 +27,7 @@ import org.junit.jupiter.params.provider.ValueSource; @ExtendWith(LoggingExtension.class) -public class CalculatorTest { +class CalculatorTest { private static Instant startedAt; @@ -40,25 +40,25 @@ public void setLogger(Logger logger) { } @BeforeEach - public void initCalculator() { + void initCalculator() { logger.info("Appel avant chaque test"); calculatorUnderTest = new Calculator(); } @AfterEach - public void undefCalculator() { + void undefCalculator() { logger.info("Appel après chaque test"); calculatorUnderTest = null; } @BeforeAll - public static void initStartingTime() { + static void initStartingTime() { System.out.println("Appel avant tous les tests"); startedAt = Instant.now(); } @AfterAll - public static void showTestDuration() { + static void showTestDuration() { System.out.println("Appel après tous les tests"); final Instant endedAt = Instant.now(); final long duration = Duration.between(startedAt, endedAt).toMillis(); @@ -66,7 +66,7 @@ public static void showTestDuration() { } @Test - public void testAddTwoPositiveNumbers() { + void testAddTwoPositiveNumbers() { // Arrange final int a = 2; final int b = 3; @@ -80,7 +80,7 @@ public void testAddTwoPositiveNumbers() { } @Test - public void multiply_shouldReturnTheProduct_ofTwoIntegers() { + void multiply_shouldReturnTheProduct_ofTwoIntegers() { // Arrange final int a = 42; final int b = 11; @@ -94,7 +94,7 @@ public void multiply_shouldReturnTheProduct_ofTwoIntegers() { @ParameterizedTest(name = "{0} x 0 doit être égal à 0") @ValueSource(ints = { 1, 2, 42, 1011, 5089 }) - public void multiply_shouldReturnZero_ofZeroWithMultipleIntegers(int arg) { + void multiply_shouldReturnZero_ofZeroWithMultipleIntegers(int arg) { // Arrange -- Tout est prêt ! // Act -- Multiplier par zéro @@ -106,7 +106,7 @@ public void multiply_shouldReturnZero_ofZeroWithMultipleIntegers(int arg) { @ParameterizedTest(name = "{0} + {1} doit être égal à {2}") @CsvSource({ "1,1,2", "2,3,5", "42,57,99" }) - public void add_shouldReturnTheSum_ofMultipleIntegers(int arg1, int arg2, int expectResult) { + void add_shouldReturnTheSum_ofMultipleIntegers(int arg1, int arg2, int expectResult) { // Arrange -- Tout est prêt ! // Act @@ -118,7 +118,7 @@ public void add_shouldReturnTheSum_ofMultipleIntegers(int arg1, int arg2, int ex @Timeout(1) @Test - public void longCalcul_shouldComputeInLessThan1Second() { + void longCalcul_shouldComputeInLessThan1Second() { // Arrange // Act @@ -129,7 +129,7 @@ public void longCalcul_shouldComputeInLessThan1Second() { } @Test - public void listDigits_shouldReturnsTheListOfDigits_ofPositiveInteger() { + void listDigits_shouldReturnsTheListOfDigits_ofPositiveInteger() { // GIVEN final int number = 95897; @@ -143,14 +143,14 @@ public void listDigits_shouldReturnsTheListOfDigits_ofPositiveInteger() { } @Test - public void listDigits_shouldReturnsTheListOfDigits_ofNegativeInteger() { + void listDigits_shouldReturnsTheListOfDigits_ofNegativeInteger() { final int number = -124432; final Set actualDigits = calculatorUnderTest.digitsSet(number); assertThat(actualDigits).containsExactlyInAnyOrder(1, 2, 3, 4); } @Test - public void listDigits_shouldReturnsTheListOfZero_ofZero() { + void listDigits_shouldReturnsTheListOfZero_ofZero() { final int number = 0; final Set actualDigits = calculatorUnderTest.digitsSet(number); assertThat(actualDigits).containsExactly(0); @@ -158,7 +158,7 @@ public void listDigits_shouldReturnsTheListOfZero_ofZero() { @Disabled("Stoppé car cela échoue tous les mardis") @Test - public void testDate() { + void testDate() { // GIVEN final LocalDateTime dateTime = LocalDateTime.now(); @@ -169,7 +169,7 @@ public void testDate() { } @Test - public void fact12_shouldReturnsTheCorrectAnswer() { + void fact12_shouldReturnsTheCorrectAnswer() { // GIVEN final int number = 12; @@ -182,7 +182,7 @@ public void fact12_shouldReturnsTheCorrectAnswer() { } @Test - public void digitsSetOfFact12_shouldReturnsTheCorrectAnswser() { + void digitsSetOfFact12_shouldReturnsTheCorrectAnswser() { // GIVEN final int cacheFactorial = 479001600; @@ -194,7 +194,7 @@ public void digitsSetOfFact12_shouldReturnsTheCorrectAnswser() { } @Test - public void multiplyAndDivide_shouldBeIdentity() { + void multiplyAndDivide_shouldBeIdentity() { // GIVEN final Random r = new Random(); final int a = 1 + r.nextInt(100); diff --git a/src/test/java/tech/zerofiltre/testing/calcul/domain/ConversionCalculatorTest.java b/src/test/java/tech/zerofiltre/testing/calcul/domain/ConversionCalculatorTest.java index 1fb80e8..188e0a8 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/domain/ConversionCalculatorTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/domain/ConversionCalculatorTest.java @@ -12,7 +12,7 @@ @Tag("ConversionTests") @DisplayName("Réussir à convertir entre différentes unités.") -public class ConversionCalculatorTest { + class ConversionCalculatorTest { private ConversionCalculator calculatorUnderTest = new ConversionCalculator(); @@ -22,14 +22,14 @@ public class ConversionCalculatorTest { class TemperatureTests { @Test @DisplayName("Soit une T° à 0°C, lorsque l'on convertit en °F, alors on obtient 32°F.") - public void celsiusToFahrenheit_returnsAFahrenheitTempurature_whenCelsiusIsZero() { + void celsiusToFahrenheit_returnsAFahrenheitTempurature_whenCelsiusIsZero() { Double actualFahrenheit = calculatorUnderTest.celsiusToFahrenheit(0.0); assertThat(actualFahrenheit).isCloseTo(32.0, withinPercentage(0.01)); } @Test @DisplayName("Soit une T° à 32°F, lorsque l'on convertit en °C, alors on obtient 0°C.") - public void fahrenheitToCelsius_returnsZeroCelciusTempurature_whenThirtyTwo() { + void fahrenheitToCelsius_returnsZeroCelciusTempurature_whenThirtyTwo() { Double actualCelsius = calculatorUnderTest.fahrenheitToCelsius(32.0); assertThat(actualCelsius).isCloseTo(0.0, withinPercentage(0.01)); } @@ -37,14 +37,14 @@ public void fahrenheitToCelsius_returnsZeroCelciusTempurature_whenThirtyTwo() { @Test @DisplayName("Soit un volume de 3.78541 litres, en gallons, on obtient 1 gallon.") - public void litresToGallons_returnsOneGallon_whenConvertingTheEquivalentLitres() { + void litresToGallons_returnsOneGallon_whenConvertingTheEquivalentLitres() { Double actualLitres = calculatorUnderTest.litresToGallons(3.78541); assertThat(actualLitres).isCloseTo(1.0, withinPercentage(0.01)); } @Test @DisplayName("L'aire d'un disque de rayon 1 doit valoir PI.") - public void radiusToAreaOfCircle_returnsPi_whenWeHaveARadiusOfOne() { + void radiusToAreaOfCircle_returnsPi_whenWeHaveARadiusOfOne() { Double actualArea = calculatorUnderTest.radiusToAreaOfCircle(1.0); assertThat(actualArea).isCloseTo(PI, withinPercentage(0.01)); } diff --git a/src/test/java/tech/zerofiltre/testing/calcul/domain/DoubleCalculatorTest.java b/src/test/java/tech/zerofiltre/testing/calcul/domain/DoubleCalculatorTest.java index 31abf37..4ea6adf 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/domain/DoubleCalculatorTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/domain/DoubleCalculatorTest.java @@ -4,17 +4,17 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -public class DoubleCalculatorTest { + class DoubleCalculatorTest { private Calculator calculatorUnderTest; @BeforeEach - public void initCalculator() { + void initCalculator() { calculatorUnderTest = new Calculator(); } @Test @Disabled("Test ambigu et hors limite du type double") - public void subTwoDoubleNumbers_shouldReturnsTheCorrectAnswer() { + void subTwoDoubleNumbers_shouldReturnsTheCorrectAnswer() { // GIVEN // WHEN diff --git a/src/test/java/tech/zerofiltre/testing/calcul/domain/StatisticsCalculatorTest.java b/src/test/java/tech/zerofiltre/testing/calcul/domain/StatisticsCalculatorTest.java index a798cd2..06df414 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/domain/StatisticsCalculatorTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/domain/StatisticsCalculatorTest.java @@ -16,7 +16,7 @@ import org.mockito.junit.jupiter.MockitoExtension; @ExtendWith(MockitoExtension.class) -public class StatisticsCalculatorTest { + class StatisticsCalculatorTest { @Spy IntSummaryStatistics summaryStatistics = new IntSummaryStatistics(); @@ -24,12 +24,12 @@ public class StatisticsCalculatorTest { StatisticsCalculator underTest; @BeforeEach - public void setUp() { + void setUp() { underTest = new StatisticsCalculator(summaryStatistics); } @Test - public void average_shouldSample_allIntegersProvided() { + void average_shouldSample_allIntegersProvided() { final ArgumentCaptor sampleCaptor = ArgumentCaptor.forClass(Integer.class); final List samples = Arrays.asList(2, 8, 5, 3, 7); @@ -41,7 +41,7 @@ public void average_shouldSample_allIntegersProvided() { } @Test - public void average_shouldReturnTheMean_ofAListOfIntegers() { + void average_shouldReturnTheMean_ofAListOfIntegers() { final List samples = Arrays.asList(2, 8, 5, 3, 7); final Integer result = underTest.average(samples); diff --git a/src/test/java/tech/zerofiltre/testing/calcul/service/BatchCalculatorServiceTest.java b/src/test/java/tech/zerofiltre/testing/calcul/service/BatchCalculatorServiceTest.java index 55f708f..89e9b91 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/service/BatchCalculatorServiceTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/service/BatchCalculatorServiceTest.java @@ -25,7 +25,7 @@ import tech.zerofiltre.testing.calcul.domain.model.CalculationType; @ExtendWith(MockitoExtension.class) -public class BatchCalculatorServiceTest { + class BatchCalculatorServiceTest { @Mock CalculatorService calculatorService; @@ -35,7 +35,7 @@ public class BatchCalculatorServiceTest { BatchCalculatorService batchCalculatorServiceNoMock; @BeforeEach - public void init() { + void init() { batchCalculatorService = new BatchCalculatorServiceImpl(calculatorService); batchCalculatorServiceNoMock = new BatchCalculatorServiceImpl( @@ -44,7 +44,7 @@ public void init() { } @Test - public void givenOperationsList_whenbatchCalculate_thenReturnsCorrectAnswerList() + void givenOperationsList_whenbatchCalculate_thenReturnsCorrectAnswerList() throws IOException, URISyntaxException { // GIVEN final Stream operations = Arrays.asList("2 + 2", "5 - 4", "6 x 8", "9 / 3").stream(); @@ -57,7 +57,7 @@ public void givenOperationsList_whenbatchCalculate_thenReturnsCorrectAnswerList( } @Test - public void givenOperationsList_whenbatchCalculate_thenCallsServiceWithCorrectArguments() { + void givenOperationsList_whenbatchCalculate_thenCallsServiceWithCorrectArguments() { // GIVEN final Stream operations = Arrays.asList("2 + 2", "5 - 4", "6 x 8", "9 / 3").stream(); final ArgumentCaptor calculationModelCaptor = ArgumentCaptor.forClass(CalculationModel.class); @@ -79,7 +79,7 @@ public void givenOperationsList_whenbatchCalculate_thenCallsServiceWithCorrectAr } @Test - public void givenOperationsList_whenbatchCalculate_thenCallsServiceAndReturnsAnswer() { + void givenOperationsList_whenbatchCalculate_thenCallsServiceAndReturnsAnswer() { // GIVEN final Stream operations = Arrays.asList("2 + 2", "5 - 4", "6 x 8", "9 / 3").stream(); when(calculatorService.calculate(any(CalculationModel.class))) @@ -113,7 +113,7 @@ public void givenOperationsList_whenbatchCalculate_thenCallsServiceAndReturnsAns } @Test - public void givenOperationsList_whenbatchCalculate_thenCallsServiceAndReturnsAnswer2() { + void givenOperationsList_whenbatchCalculate_thenCallsServiceAndReturnsAnswer2() { // GIVEN final Stream operations = Arrays.asList("2 + 2", "5 - 4", "6 x 8", "9 / 3").stream(); when(calculatorService.calculate(any(CalculationModel.class))) diff --git a/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceIT.java b/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceIT.java index 18f204b..dc6a2c3 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceIT.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceIT.java @@ -3,29 +3,28 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; - import tech.zerofiltre.testing.calcul.domain.Calculator; import tech.zerofiltre.testing.calcul.domain.model.CalculationModel; import tech.zerofiltre.testing.calcul.domain.model.CalculationType; -public class CalculatorServiceIT { +class CalculatorServiceIT { - // Mettre en place des objets réels non mockés - private final Calculator calculator = new Calculator(); - private final SolutionFormatter formatter = new SolutionFormatterImpl(); + // Mettre en place des objets réels non mockés + private final Calculator calculator = new Calculator(); + private final SolutionFormatter formatter = new SolutionFormatterImpl(); - // Initialiser la classe à tester - private final CalculatorService underTest = new CalculatorServiceImpl(calculator, formatter); + // Initialiser la classe à tester + private final CalculatorService underTest = new CalculatorServiceImpl(calculator, formatter); - @Test - public void calculatorService_shouldCalculateASolution_whenGivenACalculationModel() { - // GIVEN - final CalculationModel calculation = new CalculationModel(CalculationType.ADDITION, - 100, 101); - // WHEN - final CalculationModel result = underTest.calculate(calculation); + @Test + void calculatorService_shouldCalculateASolution_whenGivenACalculationModel() { + // GIVEN + final CalculationModel calculation = new CalculationModel(CalculationType.ADDITION, + 100, 101); + // WHEN + final CalculationModel result = underTest.calculate(calculation); - // THEN - assertThat(result.getSolution()).isEqualTo(201); - } + // THEN + assertThat(result.getSolution()).isEqualTo(201); + } } diff --git a/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceTest.java b/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceTest.java index 8c18448..a41fbca 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceTest.java @@ -9,133 +9,131 @@ import static org.mockito.Mockito.when; import java.util.Random; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; - import tech.zerofiltre.testing.calcul.domain.Calculator; import tech.zerofiltre.testing.calcul.domain.model.CalculationModel; import tech.zerofiltre.testing.calcul.domain.model.CalculationType; @ExtendWith(MockitoExtension.class) -public class CalculatorServiceTest { - - @Mock - Calculator calculator; - - @Mock - SolutionFormatter solutionFormatter; - - CalculatorService classUnderTest; - - @BeforeEach - public void init() { - classUnderTest = new CalculatorServiceImpl(calculator, solutionFormatter); - } - - @Test - public void calculate_shouldUseCalculator_forAddition() { - // GIVEN - when(calculator.add(1, 2)).thenReturn(3); - - // WHEN - final int result = classUnderTest.calculate( - new CalculationModel(CalculationType.ADDITION, 1, 2)).getSolution(); - - // THEN - verify(calculator).add(1, 2); - assertThat(result).isEqualTo(3); - } - - @Test - public void calculate_shouldUseCalculator_forSubstraction() { - // GIVEN - when(calculator.sub(3, 2)).thenReturn(1); - - // WHEN - final int result = classUnderTest.calculate( - new CalculationModel(CalculationType.SUBTRACTION, 3, 2)) - .getSolution(); - - // THEN - verify(calculator).sub(3, 2); - assertThat(result).isEqualTo(1); - } - - @Test - public void calculate_shouldUseCalculator_forMultiplication() { - // GIVEN - when(calculator.multiply(-3, 2)).thenReturn(-6); - - // WHEN - final int result = classUnderTest.calculate( - new CalculationModel(CalculationType.MULTIPLICATION, -3, 2)) - .getSolution(); - - // THEN - verify(calculator).multiply(-3, 2); - assertThat(result).isEqualTo(-6); - } - - @Test - public void calculate_shouldUseCalculator_forDivision() { - // GIVEN - when(calculator.divide(6, 3)).thenReturn(2); - - // WHEN - final int result = classUnderTest.calculate( - new CalculationModel(CalculationType.DIVISION, 6, 3)) - .getSolution(); - - // THEN - verify(calculator).divide(6, 3); - assertThat(result).isEqualTo(2); - } - - @Test - public void calculate_shouldUseCalculator_forAnyAddition() { - // GIVEN - final Random r = new Random(); - when(calculator.add(any(Integer.class), any(Integer.class))).thenReturn(3); - - // WHEN - final int result = classUnderTest.calculate( - new CalculationModel(CalculationType.ADDITION, r.nextInt(), r.nextInt())).getSolution(); - - // THEN - verify(calculator, times(1)).add(any(Integer.class), any(Integer.class)); - verify(calculator, never()).sub(any(Integer.class), any(Integer.class)); - assertThat(result).isEqualTo(3); - } - - @Test - public void calculate_shouldThrowIllegalArgumentAxception_forADivisionBy0() { - // GIVEN - when(calculator.divide(1, 0)).thenThrow(new ArithmeticException()); - - // WHEN - assertThrows(IllegalArgumentException.class, () -> classUnderTest.calculate( - new CalculationModel(CalculationType.DIVISION, 1, 0))); - - // THEN - verify(calculator, times(1)).divide(1, 0); - } - - @Test - public void calculate_shouldFormatSolution_forAnAddition() { - // GIVEN - when(calculator.add(10000, 3000)).thenReturn(13000); - when(solutionFormatter.format(13000)).thenReturn("13 000"); - - // WHEN - final String formattedResult = classUnderTest.calculate( - new CalculationModel(CalculationType.ADDITION, 10000, 3000)).getFormattedSolution(); - - // THEN - assertThat(formattedResult).isEqualTo("13 000"); - } +class CalculatorServiceTest { + + @Mock + Calculator calculator; + + @Mock + SolutionFormatter solutionFormatter; + + CalculatorService classUnderTest; + + @BeforeEach + void init() { + classUnderTest = new CalculatorServiceImpl(calculator, solutionFormatter); + } + + @Test + void calculate_shouldUseCalculator_forAddition() { + // GIVEN + when(calculator.add(1, 2)).thenReturn(3); + + // WHEN + final int result = classUnderTest.calculate( + new CalculationModel(CalculationType.ADDITION, 1, 2)).getSolution(); + + // THEN + verify(calculator).add(1, 2); + assertThat(result).isEqualTo(3); + } + + @Test + void calculate_shouldUseCalculator_forSubstraction() { + // GIVEN + when(calculator.sub(3, 2)).thenReturn(1); + + // WHEN + final int result = classUnderTest.calculate( + new CalculationModel(CalculationType.SUBTRACTION, 3, 2)) + .getSolution(); + + // THEN + verify(calculator).sub(3, 2); + assertThat(result).isEqualTo(1); + } + + @Test + void calculate_shouldUseCalculator_forMultiplication() { + // GIVEN + when(calculator.multiply(-3, 2)).thenReturn(-6); + + // WHEN + final int result = classUnderTest.calculate( + new CalculationModel(CalculationType.MULTIPLICATION, -3, 2)) + .getSolution(); + + // THEN + verify(calculator).multiply(-3, 2); + assertThat(result).isEqualTo(-6); + } + + @Test + void calculate_shouldUseCalculator_forDivision() { + // GIVEN + when(calculator.divide(6, 3)).thenReturn(2); + + // WHEN + final int result = classUnderTest.calculate( + new CalculationModel(CalculationType.DIVISION, 6, 3)) + .getSolution(); + + // THEN + verify(calculator).divide(6, 3); + assertThat(result).isEqualTo(2); + } + + @Test + void calculate_shouldUseCalculator_forAnyAddition() { + // GIVEN + final Random r = new Random(); + when(calculator.add(any(Integer.class), any(Integer.class))).thenReturn(3); + + // WHEN + final int result = classUnderTest.calculate( + new CalculationModel(CalculationType.ADDITION, r.nextInt(), r.nextInt())).getSolution(); + + // THEN + verify(calculator, times(1)).add(any(Integer.class), any(Integer.class)); + verify(calculator, never()).sub(any(Integer.class), any(Integer.class)); + assertThat(result).isEqualTo(3); + } + + @Test + void calculate_shouldThrowIllegalArgumentAxception_forADivisionBy0() { + // GIVEN + when(calculator.divide(1, 0)).thenThrow(new ArithmeticException()); + + // WHEN + assertThrows(IllegalArgumentException.class, () -> classUnderTest.calculate( + new CalculationModel(CalculationType.DIVISION, 1, 0))); + + // THEN + verify(calculator, times(1)).divide(1, 0); + } + + @Test + void calculate_shouldFormatSolution_forAnAddition() { + // GIVEN + when(calculator.add(10000, 3000)).thenReturn(13000); + when(solutionFormatter.format(13000)).thenReturn("13 000"); + + // WHEN + final String formattedResult = classUnderTest.calculate( + new CalculationModel(CalculationType.ADDITION, 10000, 3000)).getFormattedSolution(); + + // THEN + assertThat(formattedResult).isEqualTo("13 000"); + } } diff --git a/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java b/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java index 15f0006..3e3ab4a 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java @@ -5,25 +5,25 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class SolutionFormatterTest { +class SolutionFormatterTest { - private SolutionFormatter solutionFormatter; + private SolutionFormatter solutionFormatter; - @BeforeEach - public void initFormatter() { - solutionFormatter = new SolutionFormatterImpl(); - } + @BeforeEach + void initFormatter() { + solutionFormatter = new SolutionFormatterImpl(); + } - @Test - public void format_shouldFormatAnyBigNumber() { - // GIVEN - final int number = 1234567890; + @Test + void format_shouldFormatAnyBigNumber() { + // GIVEN + final int number = 1234567890; - // WHEN - final String result = solutionFormatter.format(number); + // WHEN + final String result = solutionFormatter.format(number); - // THEN - assertThat(result).isEqualTo("1 234 567 890"); - } + // THEN + assertThat(result).isEqualTo("1 234 567 890"); + } } From 4ff35cb73ac3b26368ed2bca4088f7125df6bf72 Mon Sep 17 00:00:00 2001 From: philippe SIMO Date: Sat, 21 Aug 2021 00:05:32 +0200 Subject: [PATCH 04/26] Configure Jacoco --- pom.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pom.xml b/pom.xml index 6aa21e1..cc8ec87 100644 --- a/pom.xml +++ b/pom.xml @@ -102,6 +102,26 @@ + + org.jacoco + jacoco-maven-plugin + 0.8.2 + + + + prepare-agent + + + + + report + test + + report + + + + \ No newline at end of file From 641139bb09c7f63aaaec1e158d49be9d0d357f2a Mon Sep 17 00:00:00 2001 From: philippe SIMO Date: Sat, 21 Aug 2021 00:22:33 +0200 Subject: [PATCH 05/26] Coverage ratio set up --- .../testing/calcul/domain/DoubleCalculatorTest.java | 2 +- .../testing/calcul/e2e/MultiplicationJourneyE2ETest.java | 7 +++---- .../testing/calcul/service/CalculatorServiceTest.java | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/test/java/tech/zerofiltre/testing/calcul/domain/DoubleCalculatorTest.java b/src/test/java/tech/zerofiltre/testing/calcul/domain/DoubleCalculatorTest.java index 4ea6adf..a86975f 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/domain/DoubleCalculatorTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/domain/DoubleCalculatorTest.java @@ -13,7 +13,7 @@ void initCalculator() { } @Test - @Disabled("Test ambigu et hors limite du type double") + @Disabled("Test ambigue et hors limite du type double") void subTwoDoubleNumbers_shouldReturnsTheCorrectAnswer() { // GIVEN diff --git a/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java b/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java index aff1351..73d7765 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java @@ -10,7 +10,6 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; -import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; @@ -19,7 +18,7 @@ import org.springframework.boot.web.server.LocalServerPort; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class MultiplicationJourneyE2ETest { +class MultiplicationJourneyE2ETest { @LocalServerPort private int port; @@ -47,7 +46,7 @@ void quitWebDriver() { } @Test - void multiplyTwoBySixteenMustReturn32(){ + void multiplyTwoBySixteenMustReturn32() { //GIVEN webDriver.get(baseUrl); @@ -63,7 +62,7 @@ void multiplyTwoBySixteenMustReturn32(){ submitButton.click(); //THEN - WebDriverWait waiter = new WebDriverWait(webDriver,5); + WebDriverWait waiter = new WebDriverWait(webDriver, 5); WebElement solutionElement = waiter.until(ExpectedConditions.presenceOfElementLocated(By.id("solution"))); String solution = solutionElement.getText(); assertThat(solution).isEqualTo("32"); diff --git a/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceTest.java b/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceTest.java index a41fbca..11334d6 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/service/CalculatorServiceTest.java @@ -115,8 +115,8 @@ void calculate_shouldThrowIllegalArgumentAxception_forADivisionBy0() { when(calculator.divide(1, 0)).thenThrow(new ArithmeticException()); // WHEN - assertThrows(IllegalArgumentException.class, () -> classUnderTest.calculate( - new CalculationModel(CalculationType.DIVISION, 1, 0))); + CalculationModel calculationModel = new CalculationModel(CalculationType.DIVISION, 1, 0); + assertThrows(IllegalArgumentException.class, () -> classUnderTest.calculate(calculationModel)); // THEN verify(calculator, times(1)).divide(1, 0); From b6023de38a188f42b999bcfbb75622359ad26652 Mon Sep 17 00:00:00 2001 From: philippe SIMO Date: Wed, 25 Aug 2021 04:52:28 +0200 Subject: [PATCH 06/26] Add profiles configurations --- Dockerfile | 13 +++++++++++++ entrypoint.sh | 4 ++++ src/main/resources/application-dev.yaml | 2 ++ src/main/resources/application-prod.yaml | 2 ++ src/main/resources/application-uat.yaml | 2 ++ 5 files changed, 23 insertions(+) create mode 100644 Dockerfile create mode 100644 entrypoint.sh create mode 100644 src/main/resources/application-dev.yaml create mode 100644 src/main/resources/application-prod.yaml create mode 100644 src/main/resources/application-uat.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d92b1a3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM adoptopenjdk/openjdk11:alpine-jre + +ARG JAR_FILE=target/calculator.jar + +WORKDIR /opt/app + +COPY ${JAR_FILE} calculator.jar + +COPY entrypoint.sh entrypoint.sh + +RUN chmod 755 entrypoint.sh + +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..4d68d33 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "The app is starting ..." +exec java -jar -Dspring.profiles.active=${SPRING_ACTIVE_PROFILES} "calculator.jar" \ No newline at end of file diff --git a/src/main/resources/application-dev.yaml b/src/main/resources/application-dev.yaml new file mode 100644 index 0000000..47fbb02 --- /dev/null +++ b/src/main/resources/application-dev.yaml @@ -0,0 +1,2 @@ +server: + port: 8080 \ No newline at end of file diff --git a/src/main/resources/application-prod.yaml b/src/main/resources/application-prod.yaml new file mode 100644 index 0000000..3621202 --- /dev/null +++ b/src/main/resources/application-prod.yaml @@ -0,0 +1,2 @@ +server: + port: 9001 \ No newline at end of file diff --git a/src/main/resources/application-uat.yaml b/src/main/resources/application-uat.yaml new file mode 100644 index 0000000..e346b3d --- /dev/null +++ b/src/main/resources/application-uat.yaml @@ -0,0 +1,2 @@ +server: + port: 9000 \ No newline at end of file From 8bf43ecb046ee0ae072ddad243c38bd1cb35b5c9 Mon Sep 17 00:00:00 2001 From: philippe SIMO Date: Wed, 25 Aug 2021 22:59:36 +0200 Subject: [PATCH 07/26] Add Jenkinsfile --- Jenkinsfile | 103 ++++++++ pom.xml | 247 +++++++++--------- src/main/resources/application-dev.yaml | 2 +- src/main/resources/application-prod.yaml | 2 +- src/main/resources/application-uat.yaml | 2 +- ...est.java => MultiplicationJourneyE2E.java} | 2 +- 6 files changed, 231 insertions(+), 127 deletions(-) create mode 100644 Jenkinsfile rename src/test/java/tech/zerofiltre/testing/calcul/e2e/{MultiplicationJourneyE2ETest.java => MultiplicationJourneyE2E.java} (98%) diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..97abb6f --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,103 @@ +def CONTAINER_NAME = "calculator" +def ENV_NAME = ${ getEnvName(env.BRANCH_NAME) } +def CONTAINER_TAG = ${ getTag(env.BUILD_NUMBER, env.BRANCH_NAME) } +def HTTP_PORT = ${getHTTPPort(env.BRANCH_NAME) } + + +node { + + stage('Initialize') { + def dockerHome = tool 'DockerLatest' + def mavenHome = tool 'MavenLatest' + env.PATH = "${dockerHome}/bin:${mavenHome}/bin:${env.PATH}" + } + + stage('Checkout') { + checkout scm + } + + stage('Build with test') { + sh "mvn clean install" + } + + stage('Sonarqube Analysis') { + withSonarQubeEnv('SonarQubeLocalServer') { + sh " mvn sonar:sonar -Dintegration-tests.skip=true -Dmaven.test.failure.ignore=true" + } + timeout(time: 1, unit: 'MINUTES') { + def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv + if (qg.status != 'OK') { + error "Pipeline aborted due to quality gate failure: ${qg.status}" + } + } + } + + stage("Image Prune") { + imagePrune(CONTAINER_NAME) + } + + stage('Image Build') { + imageBuild(CONTAINER_NAME, CONTAINER_TAG) + } + + stage('Push to Docker Registry') { + withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + pushToImage(CONTAINER_NAME, CONTAINER_TAG, USERNAME, PASSWORD) + } + } + + stage('Run App') { + withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + runApp(CONTAINER_NAME, CONTAINER_TAG, USERNAME, HTTP_PORT, ENV_NAME) + + } + } + +} + +def imagePrune(containerName) { + try { + sh "docker image prune -f" + sh "docker stop $containerName" + } catch (ignored) { + } +} + +def imageBuild(containerName, tag) { + sh "docker build -t $containerName:$tag -t $containerName --pull --no-cache ." + echo "Image build complete" +} + +def pushToImage(containerName, tag, dockerUser, dockerPassword) { + sh "docker login -u $dockerUser -p $dockerPassword" + sh "docker tag $containerName:$tag $dockerUser/$containerName:$tag" + sh "docker push $dockerUser/$containerName:$tag" + echo "Image push complete" +} + +def runApp(containerName, tag, dockerHubUser, httpPort,envName) { + sh "docker pull $dockerHubUser/$containerName" + sh "docker run --rm --env --env SPRING_ACTIVE_PROFILES=$envName -d -p $httpPort:$httpPort --name $containerName $dockerHubUser/$containerName:$tag" + echo "Application started on port: ${httpPort} (http)" +} + +String getEnvName(String branchName) { + if (branchName == 'main') { + return 'prod' + } + return (branchName == 'develop') ? 'uat' : 'dev' +} + +String getHTTPPort(String branchName) { + if (branchName == 'main') { + return '9003' + } + return (branchName == 'develop') ? '9002' : '9001' +} + +String getTag(String buildNumber, String branchName) { + if (branchName == 'main') { + return buildNumber + '-unstable' + } + return buildNumber + '-stable' +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index cc8ec87..1b16bd0 100644 --- a/pom.xml +++ b/pom.xml @@ -1,127 +1,128 @@ - 4.0.0 - com.openclassrooms.testing - calculator - 0.0.1-SNAPSHOT - - 5.5.2 - UTF-8 - 11 - ${maven.compiler.source} - 4.3.1 - 2.2.0.RELEASE - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + tech.zerofiltre.testing + calculator + 0.0.1-SNAPSHOT + + 5.5.2 + UTF-8 + 11 + ${maven.compiler.source} + 4.3.1 + 2.2.0.RELEASE + tech.zerofiltre.testing:calculator + - - org.springframework.boot - spring-boot-starter-parent - 2.2.0.RELEASE - + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.RELEASE + - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-devtools - runtime - - - org.webjars - bootstrap - ${bootstrap.version} - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter - test - - - org.mockito - mockito-junit-jupiter - test - - - org.assertj - assertj-core - test - - - org.apache.logging.log4j - log4j-core - - - javax.inject - javax.inject - 1 - - - org.seleniumhq.selenium - selenium-java - test - - - io.github.bonigarcia - webdrivermanager - 3.7.1 - - - - calculator - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.2 - - - - prepare-agent - - - - - report - test - - report - - - - - - + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-devtools + runtime + + + org.webjars + bootstrap + ${bootstrap.version} + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter + test + + + org.mockito + mockito-junit-jupiter + test + + + org.assertj + assertj-core + test + + + org.apache.logging.log4j + log4j-core + + + javax.inject + javax.inject + 1 + + + org.seleniumhq.selenium + selenium-java + test + + + io.github.bonigarcia + webdrivermanager + 3.7.1 + + + + calculator + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + integration-test + verify + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.2 + + + + prepare-agent + + + + + report + test + + report + + + + + + \ No newline at end of file diff --git a/src/main/resources/application-dev.yaml b/src/main/resources/application-dev.yaml index 47fbb02..3621202 100644 --- a/src/main/resources/application-dev.yaml +++ b/src/main/resources/application-dev.yaml @@ -1,2 +1,2 @@ server: - port: 8080 \ No newline at end of file + port: 9001 \ No newline at end of file diff --git a/src/main/resources/application-prod.yaml b/src/main/resources/application-prod.yaml index 3621202..9beecae 100644 --- a/src/main/resources/application-prod.yaml +++ b/src/main/resources/application-prod.yaml @@ -1,2 +1,2 @@ server: - port: 9001 \ No newline at end of file + port: 9003 \ No newline at end of file diff --git a/src/main/resources/application-uat.yaml b/src/main/resources/application-uat.yaml index e346b3d..5af7893 100644 --- a/src/main/resources/application-uat.yaml +++ b/src/main/resources/application-uat.yaml @@ -1,2 +1,2 @@ server: - port: 9000 \ No newline at end of file + port: 9002 \ No newline at end of file diff --git a/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java b/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2E.java similarity index 98% rename from src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java rename to src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2E.java index 73d7765..24eac6f 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2ETest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/e2e/MultiplicationJourneyE2E.java @@ -18,7 +18,7 @@ import org.springframework.boot.web.server.LocalServerPort; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -class MultiplicationJourneyE2ETest { +class MultiplicationJourneyE2E { @LocalServerPort private int port; From 8e32b213d73f7c9b9ebe74c41a1c6ccc81b50125 Mon Sep 17 00:00:00 2001 From: philippe SIMO Date: Thu, 26 Aug 2021 22:40:33 +0200 Subject: [PATCH 08/26] Send email after pipeline --- Jenkinsfile | 92 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 39 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 97abb6f..57d3199 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,56 +1,63 @@ def CONTAINER_NAME = "calculator" -def ENV_NAME = ${ getEnvName(env.BRANCH_NAME) } -def CONTAINER_TAG = ${ getTag(env.BUILD_NUMBER, env.BRANCH_NAME) } -def HTTP_PORT = ${getHTTPPort(env.BRANCH_NAME) } +def ENV_NAME = getEnvName(env.BRANCH_NAME) +def CONTAINER_TAG = getTag(env.BUILD_NUMBER, env.BRANCH_NAME) +def HTTP_PORT = getHTTPPort(env.BRANCH_NAME) +def EMAIL_RECIPIENTS = "philippe.guemkamsimo@gmail.com" node { + try { + stage('Initialize') { + def dockerHome = tool 'DockerLatest' + def mavenHome = tool 'MavenLatest' + env.PATH = "${dockerHome}/bin:${mavenHome}/bin:${env.PATH}" + } - stage('Initialize') { - def dockerHome = tool 'DockerLatest' - def mavenHome = tool 'MavenLatest' - env.PATH = "${dockerHome}/bin:${mavenHome}/bin:${env.PATH}" - } + stage('Checkout') { + checkout scm + } - stage('Checkout') { - checkout scm - } + stage('Build with test') { - stage('Build with test') { - sh "mvn clean install" - } - - stage('Sonarqube Analysis') { - withSonarQubeEnv('SonarQubeLocalServer') { - sh " mvn sonar:sonar -Dintegration-tests.skip=true -Dmaven.test.failure.ignore=true" + sh "mvn clean install" } - timeout(time: 1, unit: 'MINUTES') { - def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv - if (qg.status != 'OK') { - error "Pipeline aborted due to quality gate failure: ${qg.status}" + + stage('Sonarqube Analysis') { + withSonarQubeEnv('SonarQubeLocalServer') { + sh " mvn sonar:sonar -Dintegration-tests.skip=true -Dmaven.test.failure.ignore=true" + } + timeout(time: 1, unit: 'MINUTES') { + def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv + if (qg.status != 'OK') { + error "Pipeline aborted due to quality gate failure: ${qg.status}" + } } } - } - stage("Image Prune") { - imagePrune(CONTAINER_NAME) - } + stage("Image Prune") { + imagePrune(CONTAINER_NAME) + } - stage('Image Build') { - imageBuild(CONTAINER_NAME, CONTAINER_TAG) - } + stage('Image Build') { + imageBuild(CONTAINER_NAME, CONTAINER_TAG) + } - stage('Push to Docker Registry') { - withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { - pushToImage(CONTAINER_NAME, CONTAINER_TAG, USERNAME, PASSWORD) + stage('Push to Docker Registry') { + withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + pushToImage(CONTAINER_NAME, CONTAINER_TAG, USERNAME, PASSWORD) + } } - } - stage('Run App') { - withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { - runApp(CONTAINER_NAME, CONTAINER_TAG, USERNAME, HTTP_PORT, ENV_NAME) + stage('Run App') { + withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + runApp(CONTAINER_NAME, CONTAINER_TAG, USERNAME, HTTP_PORT, ENV_NAME) + } } + + } finally { + deleteDir() + sendEmail(EMAIL_RECIPIENTS); } } @@ -75,12 +82,19 @@ def pushToImage(containerName, tag, dockerUser, dockerPassword) { echo "Image push complete" } -def runApp(containerName, tag, dockerHubUser, httpPort,envName) { +def runApp(containerName, tag, dockerHubUser, httpPort, envName) { sh "docker pull $dockerHubUser/$containerName" - sh "docker run --rm --env --env SPRING_ACTIVE_PROFILES=$envName -d -p $httpPort:$httpPort --name $containerName $dockerHubUser/$containerName:$tag" + sh "docker run --rm --env SPRING_ACTIVE_PROFILES=$envName -d -p $httpPort:$httpPort --name $containerName $dockerHubUser/$containerName:$tag" echo "Application started on port: ${httpPort} (http)" } +def sendEmail(recipients) { + mail( + to: recipients, + subject: "Build ${env.BUILD_NUMBER} - ${currentBuild.currentResult} - (${currentBuild.fullDisplayName})", + body: "Check console output at: ${env.BUILD_URL}/console" + "\n") +} + String getEnvName(String branchName) { if (branchName == 'main') { return 'prod' @@ -100,4 +114,4 @@ String getTag(String buildNumber, String branchName) { return buildNumber + '-unstable' } return buildNumber + '-stable' -} \ No newline at end of file +} From 4e28d9c366d876ddcfd1c6e0bf05ee1914b548aa Mon Sep 17 00:00:00 2001 From: Philippe GUEMKAM Date: Wed, 26 Jun 2024 15:38:34 +0200 Subject: [PATCH 09/26] Use your own email please, not mine --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 57d3199..7f0719a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ def CONTAINER_NAME = "calculator" def ENV_NAME = getEnvName(env.BRANCH_NAME) def CONTAINER_TAG = getTag(env.BUILD_NUMBER, env.BRANCH_NAME) def HTTP_PORT = getHTTPPort(env.BRANCH_NAME) -def EMAIL_RECIPIENTS = "philippe.guemkamsimo@gmail.com" +def EMAIL_RECIPIENTS = "your_email@gmail.com" node { From 14e3f7d33adbc122e00d81974c54f5a1c1606dfc Mon Sep 17 00:00:00 2001 From: oullmed Date: Tue, 9 Dec 2025 16:28:50 +0100 Subject: [PATCH 10/26] modification du fichier jenkins --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7f0719a..ffc3e7a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,8 @@ -def CONTAINER_NAME = "calculator" def ENV_NAME = getEnvName(env.BRANCH_NAME) +def CONTAINER_NAME = "calculator-"+ENV_NAME def CONTAINER_TAG = getTag(env.BUILD_NUMBER, env.BRANCH_NAME) def HTTP_PORT = getHTTPPort(env.BRANCH_NAME) -def EMAIL_RECIPIENTS = "your_email@gmail.com" +def EMAIL_RECIPIENTS = "oullemine.med@gmail.com" node { @@ -43,13 +43,13 @@ node { } stage('Push to Docker Registry') { - withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + withCredentials([usernamePassword(credentialsId: 'dockerhubcredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { pushToImage(CONTAINER_NAME, CONTAINER_TAG, USERNAME, PASSWORD) } } stage('Run App') { - withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + withCredentials([usernamePassword(credentialsId: 'dockerhubcredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { runApp(CONTAINER_NAME, CONTAINER_TAG, USERNAME, HTTP_PORT, ENV_NAME) } @@ -96,21 +96,21 @@ def sendEmail(recipients) { } String getEnvName(String branchName) { - if (branchName == 'main') { + if (branchName == 'master') { return 'prod' } return (branchName == 'develop') ? 'uat' : 'dev' } String getHTTPPort(String branchName) { - if (branchName == 'main') { + if (branchName == 'master') { return '9003' } return (branchName == 'develop') ? '9002' : '9001' } String getTag(String buildNumber, String branchName) { - if (branchName == 'main') { + if (branchName != 'master') { return buildNumber + '-unstable' } return buildNumber + '-stable' From 33628deaa0fcd67c8b09f3e95f2f174d16ecbd5a Mon Sep 17 00:00:00 2001 From: oullmed Date: Tue, 9 Dec 2025 17:46:06 +0100 Subject: [PATCH 11/26] modification du fichier jenkins(master=>main) --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ffc3e7a..20b5066 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -96,21 +96,21 @@ def sendEmail(recipients) { } String getEnvName(String branchName) { - if (branchName == 'master') { + if (branchName == 'main') { return 'prod' } return (branchName == 'develop') ? 'uat' : 'dev' } String getHTTPPort(String branchName) { - if (branchName == 'master') { + if (branchName == 'main') { return '9003' } return (branchName == 'develop') ? '9002' : '9001' } String getTag(String buildNumber, String branchName) { - if (branchName != 'master') { + if (branchName != 'main') { return buildNumber + '-unstable' } return buildNumber + '-stable' From 94213b4d6d43d2e48f24a276d5b8609295c4f118 Mon Sep 17 00:00:00 2001 From: oullmed Date: Tue, 9 Dec 2025 17:53:19 +0100 Subject: [PATCH 12/26] modification du fichier jenkins --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7f0719a..20b5066 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,8 @@ -def CONTAINER_NAME = "calculator" def ENV_NAME = getEnvName(env.BRANCH_NAME) +def CONTAINER_NAME = "calculator-"+ENV_NAME def CONTAINER_TAG = getTag(env.BUILD_NUMBER, env.BRANCH_NAME) def HTTP_PORT = getHTTPPort(env.BRANCH_NAME) -def EMAIL_RECIPIENTS = "your_email@gmail.com" +def EMAIL_RECIPIENTS = "oullemine.med@gmail.com" node { @@ -43,13 +43,13 @@ node { } stage('Push to Docker Registry') { - withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + withCredentials([usernamePassword(credentialsId: 'dockerhubcredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { pushToImage(CONTAINER_NAME, CONTAINER_TAG, USERNAME, PASSWORD) } } stage('Run App') { - withCredentials([usernamePassword(credentialsId: 'DockerhubCredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { + withCredentials([usernamePassword(credentialsId: 'dockerhubcredentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { runApp(CONTAINER_NAME, CONTAINER_TAG, USERNAME, HTTP_PORT, ENV_NAME) } @@ -110,7 +110,7 @@ String getHTTPPort(String branchName) { } String getTag(String buildNumber, String branchName) { - if (branchName == 'main') { + if (branchName != 'main') { return buildNumber + '-unstable' } return buildNumber + '-stable' From 7185822362e55c38757a846394e9582a96f37456 Mon Sep 17 00:00:00 2001 From: oullmed Date: Tue, 9 Dec 2025 18:08:42 +0100 Subject: [PATCH 13/26] modification du fichier pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1b16bd0..ada7d6d 100644 --- a/pom.xml +++ b/pom.xml @@ -106,7 +106,7 @@ org.jacoco jacoco-maven-plugin - 0.8.2 + 0.8.11 From 5282e88f85efe78fe0806301c79072da56d246dc Mon Sep 17 00:00:00 2001 From: oullmed Date: Tue, 9 Dec 2025 18:17:09 +0100 Subject: [PATCH 14/26] modification du fichier SolutionFormatterTest.java --- .../testing/calcul/service/SolutionFormatterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java b/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java index 3e3ab4a..8d03e5e 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java @@ -23,7 +23,7 @@ void format_shouldFormatAnyBigNumber() { final String result = solutionFormatter.format(number); // THEN - assertThat(result).isEqualTo("1 234 567 890"); + assertThat(result).isEqualTo("1 234 567 890"); } } From 6cb8caee9cfbd96e8cdf2a4bc583af75fc347cc6 Mon Sep 17 00:00:00 2001 From: oullmed Date: Tue, 9 Dec 2025 18:21:58 +0100 Subject: [PATCH 15/26] modification du fichier SolutionFormatterTest.java --- .../testing/calcul/service/SolutionFormatterTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java b/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java index 8d03e5e..778927f 100644 --- a/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java +++ b/src/test/java/tech/zerofiltre/testing/calcul/service/SolutionFormatterTest.java @@ -22,8 +22,14 @@ void format_shouldFormatAnyBigNumber() { // WHEN final String result = solutionFormatter.format(number); + // THEN - assertThat(result).isEqualTo("1 234 567 890"); + String normalized = result + .replace('\u00A0', ' ') // NBSP -> space + .replace('\u202F', ' '); // narrow NBSP -> space + + assertThat(normalized).isEqualTo("1 234 567 890"); + } } From 26ed2baf6ca48298bb10db5205e8734c2c5783b8 Mon Sep 17 00:00:00 2001 From: oullmed Date: Wed, 10 Dec 2025 16:06:34 +0100 Subject: [PATCH 16/26] modification de l'amil de reciption --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 20b5066..6e4ded6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ def ENV_NAME = getEnvName(env.BRANCH_NAME) def CONTAINER_NAME = "calculator-"+ENV_NAME def CONTAINER_TAG = getTag(env.BUILD_NUMBER, env.BRANCH_NAME) def HTTP_PORT = getHTTPPort(env.BRANCH_NAME) -def EMAIL_RECIPIENTS = "oullemine.med@gmail.com" +def EMAIL_RECIPIENTS = "oullmedacademy1@gmail.com" node { From e965a499e60fa3f20fdac5dddbcc67dac493f3cc Mon Sep 17 00:00:00 2001 From: oullmed Date: Wed, 10 Dec 2025 16:22:41 +0100 Subject: [PATCH 17/26] modification de la valeur du waitForQualityGate --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6e4ded6..afc4aa5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,7 +26,7 @@ node { withSonarQubeEnv('SonarQubeLocalServer') { sh " mvn sonar:sonar -Dintegration-tests.skip=true -Dmaven.test.failure.ignore=true" } - timeout(time: 1, unit: 'MINUTES') { + timeout(time: 10, unit: 'MINUTES') { def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv if (qg.status != 'OK') { error "Pipeline aborted due to quality gate failure: ${qg.status}" From 9e5f32bdd7a0f6cf96c2a963b50ec44e1c2bbba3 Mon Sep 17 00:00:00 2001 From: oullmed Date: Wed, 10 Dec 2025 20:25:25 +0100 Subject: [PATCH 18/26] modification de la valeur de imageBuild et runApp --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index afc4aa5..3b8329d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,7 +71,7 @@ def imagePrune(containerName) { } def imageBuild(containerName, tag) { - sh "docker build -t $containerName:$tag -t $containerName --pull --no-cache ." + sh "docker build -t $containerName:$tag --pull --no-cache ." echo "Image build complete" } @@ -83,7 +83,7 @@ def pushToImage(containerName, tag, dockerUser, dockerPassword) { } def runApp(containerName, tag, dockerHubUser, httpPort, envName) { - sh "docker pull $dockerHubUser/$containerName" + sh "docker pull $dockerHubUser/$containerName:$tag" sh "docker run --rm --env SPRING_ACTIVE_PROFILES=$envName -d -p $httpPort:$httpPort --name $containerName $dockerHubUser/$containerName:$tag" echo "Application started on port: ${httpPort} (http)" } From d07b1b6234e64181eb5b056ea57213470f1c4ccc Mon Sep 17 00:00:00 2001 From: oullmed Date: Fri, 12 Dec 2025 20:03:52 +0100 Subject: [PATCH 19/26] modification du fichier Jenkions avec le forcage de l'url sonar --- Jenkinsfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3b8329d..b51915b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,14 @@ node { stage('Sonarqube Analysis') { withSonarQubeEnv('SonarQubeLocalServer') { - sh " mvn sonar:sonar -Dintegration-tests.skip=true -Dmaven.test.failure.ignore=true" + + sh ''' + mvn sonar:sonar \ + -Dsonar.host.url=http://sonarqube:9000 \ + -Dintegration-tests.skip=true \ + -Dmaven.test.failure.ignore=true + ''' + } timeout(time: 10, unit: 'MINUTES') { def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv From a2c88c7c0a43f94588de4bf1ae9a33ab0f43fbd2 Mon Sep 17 00:00:00 2001 From: oullmed Date: Fri, 12 Dec 2025 20:38:43 +0100 Subject: [PATCH 20/26] modification du fichier Jenkions avec le forcage de l'url sonar --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index b51915b..1b0b037 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -78,6 +78,7 @@ def imagePrune(containerName) { } def imageBuild(containerName, tag) { + sh 'docker version' // doit afficher un client et un serveur sh "docker build -t $containerName:$tag --pull --no-cache ." echo "Image build complete" } From a370045dcaf377d95360ddf9dc45b126fb94cf41 Mon Sep 17 00:00:00 2001 From: oullmed Date: Fri, 12 Dec 2025 20:56:18 +0100 Subject: [PATCH 21/26] modification du fichier Jenkions avec le forcage de l'url sonar --- Jenkinsfile | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1b0b037..36c1a22 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,6 +45,19 @@ node { imagePrune(CONTAINER_NAME) } + stage('Docker sanity') { + steps { + sh ''' + set -euo pipefail + echo "PATH: $PATH" + echo "which docker: $(which docker || true)" + echo "readlink docker: $(readlink -f $(which docker) || true)" + /usr/bin/docker -v + /usr/bin/docker version + ''' + } + } + stage('Image Build') { imageBuild(CONTAINER_NAME, CONTAINER_TAG) } @@ -77,12 +90,21 @@ def imagePrune(containerName) { } } + +//def imageBuild(containerName, tag) { +// sh 'docker version' // doit afficher un client et un serveur +// sh "docker build -t $containerName:$tag --pull --no-cache ." +// echo "Image build complete" +//} + + def imageBuild(containerName, tag) { - sh 'docker version' // doit afficher un client et un serveur - sh "docker build -t $containerName:$tag --pull --no-cache ." + sh '/usr/bin/docker version' // Client 26.x + API 1.45 + sh "/usr/bin/docker build -t ${containerName}:${tag} --pull --no-cache ." echo "Image build complete" } + def pushToImage(containerName, tag, dockerUser, dockerPassword) { sh "docker login -u $dockerUser -p $dockerPassword" sh "docker tag $containerName:$tag $dockerUser/$containerName:$tag" From 1d23834578a4dd07fe8ebe24f31a078b40d4e28a Mon Sep 17 00:00:00 2001 From: oullmed Date: Fri, 12 Dec 2025 21:05:47 +0100 Subject: [PATCH 22/26] modification du fichier Jenkions avec le forcage de l'url sonar --- Jenkinsfile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 36c1a22..c57c822 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ node { stage('Initialize') { def dockerHome = tool 'DockerLatest' def mavenHome = tool 'MavenLatest' - env.PATH = "${dockerHome}/bin:${mavenHome}/bin:${env.PATH}" + env.PATH = "/usr/bin:/bin:${env.PATH}:${mavenHome}/bin" } stage('Checkout') { @@ -46,16 +46,16 @@ node { } stage('Docker sanity') { - steps { - sh ''' - set -euo pipefail - echo "PATH: $PATH" - echo "which docker: $(which docker || true)" - echo "readlink docker: $(readlink -f $(which docker) || true)" - /usr/bin/docker -v - /usr/bin/docker version - ''' - } + + sh ''' + set -euo pipefail + echo "PATH: $PATH" + echo "which docker: $(which docker || true)" + echo "readlink docker: $(readlink -f $(which docker) || true)" + /usr/bin/docker -v + /usr/bin/docker version + ''' + } stage('Image Build') { From 0945e14ef2872ca9a636d7e7aafab16248fa0997 Mon Sep 17 00:00:00 2001 From: oullmed Date: Fri, 12 Dec 2025 21:42:52 +0100 Subject: [PATCH 23/26] changement du SPRING_PROFILES_ACTIVE --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 24326c2..b6cff1f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -113,7 +113,7 @@ def pushToImage(containerName, tag, dockerUser, dockerPassword) { def runApp(containerName, tag, dockerHubUser, httpPort, envName) { sh "docker pull $dockerHubUser/$containerName:$tag" - sh "docker run --rm --env SPRING_ACTIVE_PROFILES=$envName -d -p $httpPort:$httpPort --name $containerName $dockerHubUser/$containerName:$tag" + sh "docker run --rm --env SPRING_PROFILES_ACTIVE=$envName -d -p $httpPort:$httpPort --name $containerName $dockerHubUser/$containerName:$tag" echo "Application started on port: ${httpPort} (http)" } From 67d3b9111ccdd617d472a7836d5dc8c6d67fbadf Mon Sep 17 00:00:00 2001 From: oullmed Date: Mon, 15 Dec 2025 16:45:07 +0100 Subject: [PATCH 24/26] changement du SPRING_PROFILES_ACTIVE dans entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4d68d33..a0cd232 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ #!/bin/sh echo "The app is starting ..." -exec java -jar -Dspring.profiles.active=${SPRING_ACTIVE_PROFILES} "calculator.jar" \ No newline at end of file +exec java -jar -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} "calculator.jar" \ No newline at end of file From af055c632f1b92ef5b0f873e3d4df8b226e61182 Mon Sep 17 00:00:00 2001 From: oullmed Date: Mon, 15 Dec 2025 21:25:03 +0100 Subject: [PATCH 25/26] changement du SPRING_PROFILES_ACTIVE dans entrypoint.sh --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4d68d33..a0cd232 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ #!/bin/sh echo "The app is starting ..." -exec java -jar -Dspring.profiles.active=${SPRING_ACTIVE_PROFILES} "calculator.jar" \ No newline at end of file +exec java -jar -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} "calculator.jar" \ No newline at end of file From 715764eb92a12486fad515c254b9ac1009530a95 Mon Sep 17 00:00:00 2001 From: oullmed Date: Mon, 15 Dec 2025 21:43:54 +0100 Subject: [PATCH 26/26] changement du titre de l'application --- src/main/resources/templates/calculator.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/templates/calculator.html b/src/main/resources/templates/calculator.html index 277575c..39e09e9 100644 --- a/src/main/resources/templates/calculator.html +++ b/src/main/resources/templates/calculator.html @@ -4,7 +4,7 @@ - Calculateur du cours de tests OpenClassrooms + Calculateur du cours de tests @@ -13,7 +13,7 @@
- Open Calculator + The Open Calculator