From bdee7cca0f76323c27e6752cdcbfb3d44cfc86a6 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 19:22:24 +0200 Subject: [PATCH 01/21] Crear pom.xml inicial para integrar Maven y SonarQube --- pom.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pom.xml diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..f3b55090 --- /dev/null +++ b/pom.xml @@ -0,0 +1,26 @@ + + 4.0.0 + + com.ivanfpardo + refactoring-fowler-example + 1.0-SNAPSHOT + + + UTF-8 + 11 + 11 + + + + + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.9.1.2184 + + + + From 68e5f9ba9ed20aaf32075b5715529fb530ee2bfd Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 19:25:13 +0200 Subject: [PATCH 02/21] =?UTF-8?q?A=C3=B1adir=20flujo=20de=20trabajo=20GitH?= =?UTF-8?q?ub=20Actions=20para=20el=20an=C3=A1lisis=20SonarCloud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sonarcloud.yml | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/sonarcloud.yml diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 00000000..947ed649 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,40 @@ +name: Build and analyze with SonarCloud + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] + branches: + - main + +jobs: + build: + name: Build and SonarCloud Analysis + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven + + - name: Build and analyze + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn clean verify sonar:sonar \ + -Dsonar.projectKey=IVANFPARDO_refactoring-fowler-example \ + -Dsonar.organization=ivanfpardo \ + -Dsonar.host.url=https://sonarcloud.io From 5492b56c8c1daa620279130c46c7db065e2e027d Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 19:33:45 +0200 Subject: [PATCH 03/21] =?UTF-8?q?se=20a=C3=B1ade=20comentario=20en=20la=20?= =?UTF-8?q?l=C3=ADnea=209=20del=20=20pom.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f3b55090..331cbbe7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ivanfpardo refactoring-fowler-example - 1.0-SNAPSHOT + 1.0-SNAPSHOT UTF-8 From e4987e2a5b0fba1d34dcc92913e79b3610d246d3 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 19:45:03 +0200 Subject: [PATCH 04/21] activar workflow en rama master --- .github/workflows/sonarcloud.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 947ed649..a00826f7 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -3,11 +3,11 @@ name: Build and analyze with SonarCloud on: push: branches: - - main + - master pull_request: types: [opened, synchronize, reopened] branches: - - main + - master jobs: build: From cb63e3ed82f6e79dffb097ae1acf9e0741c4fedd Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 19:47:25 +0200 Subject: [PATCH 05/21] =?UTF-8?q?A=C3=B1adir=20url=20al=20pom.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 331cbbe7..58e9d376 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,7 @@ com.ivanfpardo refactoring-fowler-example 1.0-SNAPSHOT + https://github.com/IVANFPARDO/refactoring-fowler-example UTF-8 From ed852366823b15ef29507fd32c92f5afc71e254b Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 19:55:23 +0200 Subject: [PATCH 06/21] Actualizar sonartoken sonarcloud.yml --- .github/workflows/sonarcloud.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index a00826f7..f77a6713 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -34,7 +34,8 @@ jobs: - name: Build and analyze env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn clean verify sonar:sonar \ + run: mvn clean verify sonar:sonar -- \ -Dsonar.projectKey=IVANFPARDO_refactoring-fowler-example \ -Dsonar.organization=ivanfpardo \ -Dsonar.host.url=https://sonarcloud.io + From 86022b78fb8e90b278da6be194ea80cb80e011fe Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 19:56:26 +0200 Subject: [PATCH 07/21] Test 2 pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 58e9d376..8c44a926 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ivanfpardo refactoring-fowler-example - 1.0-SNAPSHOT + 1.0-SNAPSHOT https://github.com/IVANFPARDO/refactoring-fowler-example From 07a710adf577fe116dfb8ad8ecba5be1a9fafd67 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:00:34 +0200 Subject: [PATCH 08/21] Update sonarcloud.yml --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index f77a6713..cbb6d76f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -34,7 +34,7 @@ jobs: - name: Build and analyze env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn clean verify sonar:sonar -- \ + run: mvn clean verify sonar:sonar --\ -Dsonar.projectKey=IVANFPARDO_refactoring-fowler-example \ -Dsonar.organization=ivanfpardo \ -Dsonar.host.url=https://sonarcloud.io From dcf1af6171f8ab4cf8662639cee53686e757d9d7 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:01:27 +0200 Subject: [PATCH 09/21] test 3 pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8c44a926..a7790e0c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ivanfpardo refactoring-fowler-example - 1.0-SNAPSHOT + 1.0-SNAPSHOT https://github.com/IVANFPARDO/refactoring-fowler-example From ac024191753c6f2992c5b45dc0250c1911886c77 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:05:11 +0200 Subject: [PATCH 10/21] =?UTF-8?q?Actualizaci=C3=B3n=203=20de=20=20sonarclo?= =?UTF-8?q?ud.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sonarcloud.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index cbb6d76f..40086703 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -34,8 +34,6 @@ jobs: - name: Build and analyze env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn clean verify sonar:sonar --\ - -Dsonar.projectKey=IVANFPARDO_refactoring-fowler-example \ - -Dsonar.organization=ivanfpardo \ - -Dsonar.host.url=https://sonarcloud.io + run: mvn clean verify sonar:sonar -Dsonar.projectKey=IVANFPARDO_refactoring-fowler-example -Dsonar.organization=ivanfpardo -Dsonar.host.url=https://sonarcloud.io + From 046387dd7ecb0f31454ee23ac3b3d41864ec2b8d Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:05:49 +0200 Subject: [PATCH 11/21] test 4 pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a7790e0c..2e3abc2c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ivanfpardo refactoring-fowler-example - 1.0-SNAPSHOT + 1.0-SNAPSHOT https://github.com/IVANFPARDO/refactoring-fowler-example From 17ec7163fd355cf92287fd27883ae1347519f131 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:09:28 +0200 Subject: [PATCH 12/21] actualizar a jdk-17 para compatibilidad con sonar-maven --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 40086703..409d0476 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -22,7 +22,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '11' + java-version: '17' - name: Cache Maven packages uses: actions/cache@v3 From fda82c399635ed1909d0528847538853f2387bb3 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:09:57 +0200 Subject: [PATCH 13/21] test 5 pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2e3abc2c..71bf9aee 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ivanfpardo refactoring-fowler-example - 1.0-SNAPSHOT + 1.0-SNAPSHOT https://github.com/IVANFPARDO/refactoring-fowler-example From c3eca4b8535000d2be8913a6f2519406671e533c Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:18:27 +0200 Subject: [PATCH 14/21] refactor: mover archivos a estructura Maven para SonarCloud --- .../com/ivanfpardo}/refactoring/Customer.java | 150 +++++++++--------- .../com/ivanfpardo}/refactoring/Movie.java | 76 ++++----- .../com/ivanfpardo}/refactoring/Rental.java | 60 +++---- .../refactoring/VideoClubAplicacion.java | 44 ++--- .../refactoring/VideoClubTest.java | 118 +++++++------- 5 files changed, 224 insertions(+), 224 deletions(-) rename src/{ubu/gii/dass => main/java/com/ivanfpardo}/refactoring/Customer.java (96%) rename src/{ubu/gii/dass => main/java/com/ivanfpardo}/refactoring/Movie.java (95%) rename src/{ubu/gii/dass => main/java/com/ivanfpardo}/refactoring/Rental.java (94%) rename src/{ubu/gii/dass => main/java/com/ivanfpardo}/refactoring/VideoClubAplicacion.java (95%) rename src/{ubu/gii/dass => test/java/com/ivanfpardo}/refactoring/VideoClubTest.java (95%) diff --git a/src/ubu/gii/dass/refactoring/Customer.java b/src/main/java/com/ivanfpardo/refactoring/Customer.java similarity index 96% rename from src/ubu/gii/dass/refactoring/Customer.java rename to src/main/java/com/ivanfpardo/refactoring/Customer.java index a5631232..bb22f1a2 100644 --- a/src/ubu/gii/dass/refactoring/Customer.java +++ b/src/main/java/com/ivanfpardo/refactoring/Customer.java @@ -1,75 +1,75 @@ -package ubu.gii.dass.refactoring; - -/** -* Tema Refactorizaciones -* -* Ejemplo de aplicaci�n de refactorizaciones. Actualizado para colecciones gen�ricas de java 1.5 -* -* @author M. Fowler y Carlos L�pez -* @version 1.1 -* @see java.io.File -* -*/ -import java.util.*; - -public class Customer { - private String _name; - private List _rentals; - - public Customer(String name) { - _name = name; - _rentals = new ArrayList(); - - }; - - public void addRental(Rental arg) { - _rentals.add(arg); - } - - public String getName() { - return _name; - }; - - public String statement() { - double totalAmount = 0; - int frequentRenterPoints = 0; - Iterator rentals = _rentals.iterator(); - String result = "Rental Record for " + getName() + "\n"; - while (rentals.hasNext()) { - double thisAmount = 0; - Rental each = rentals.next(); - // determine amounts for each line - switch (each.getMovie().getPriceCode()) { - case Movie.REGULAR: - thisAmount += 2; - if (each.getDaysRented() > 2) - thisAmount += (each.getDaysRented() - 2) * 1.5; - break; - case Movie.NEW_RELEASE: - thisAmount += each.getDaysRented() * 3; - break; - case Movie.CHILDRENS: - thisAmount += 1.5; - if (each.getDaysRented() > 3) - thisAmount += (each.getDaysRented() - 3) * 1.5; - break; - } - - // add frequent renter points - frequentRenterPoints++; - // add bonus for a two day new release rental - if ((each.getMovie().getPriceCode() == Movie.NEW_RELEASE) - && each.getDaysRented() > 1) - frequentRenterPoints++; - // show figures for this rental - result += "\t" + each.getMovie().getTitle() + "\t" - + String.valueOf(thisAmount) + "\n"; - totalAmount += thisAmount; - } - // add footer lines - result += "Amount owed is " + String.valueOf(totalAmount) + "\n"; - result += "You earned " + String.valueOf(frequentRenterPoints) - + " frequent renter points"; - return result; - } -} +package ubu.gii.dass.refactoring; + +/** +* Tema Refactorizaciones +* +* Ejemplo de aplicaci�n de refactorizaciones. Actualizado para colecciones gen�ricas de java 1.5 +* +* @author M. Fowler y Carlos L�pez +* @version 1.1 +* @see java.io.File +* +*/ +import java.util.*; + +public class Customer { + private String _name; + private List _rentals; + + public Customer(String name) { + _name = name; + _rentals = new ArrayList(); + + }; + + public void addRental(Rental arg) { + _rentals.add(arg); + } + + public String getName() { + return _name; + }; + + public String statement() { + double totalAmount = 0; + int frequentRenterPoints = 0; + Iterator rentals = _rentals.iterator(); + String result = "Rental Record for " + getName() + "\n"; + while (rentals.hasNext()) { + double thisAmount = 0; + Rental each = rentals.next(); + // determine amounts for each line + switch (each.getMovie().getPriceCode()) { + case Movie.REGULAR: + thisAmount += 2; + if (each.getDaysRented() > 2) + thisAmount += (each.getDaysRented() - 2) * 1.5; + break; + case Movie.NEW_RELEASE: + thisAmount += each.getDaysRented() * 3; + break; + case Movie.CHILDRENS: + thisAmount += 1.5; + if (each.getDaysRented() > 3) + thisAmount += (each.getDaysRented() - 3) * 1.5; + break; + } + + // add frequent renter points + frequentRenterPoints++; + // add bonus for a two day new release rental + if ((each.getMovie().getPriceCode() == Movie.NEW_RELEASE) + && each.getDaysRented() > 1) + frequentRenterPoints++; + // show figures for this rental + result += "\t" + each.getMovie().getTitle() + "\t" + + String.valueOf(thisAmount) + "\n"; + totalAmount += thisAmount; + } + // add footer lines + result += "Amount owed is " + String.valueOf(totalAmount) + "\n"; + result += "You earned " + String.valueOf(frequentRenterPoints) + + " frequent renter points"; + return result; + } +} diff --git a/src/ubu/gii/dass/refactoring/Movie.java b/src/main/java/com/ivanfpardo/refactoring/Movie.java similarity index 95% rename from src/ubu/gii/dass/refactoring/Movie.java rename to src/main/java/com/ivanfpardo/refactoring/Movie.java index c5e768f2..8d522154 100644 --- a/src/ubu/gii/dass/refactoring/Movie.java +++ b/src/main/java/com/ivanfpardo/refactoring/Movie.java @@ -1,38 +1,38 @@ -package ubu.gii.dass.refactoring; -/** - * Tema Refactorizaciones - * - * Ejemplo de aplicación de refactorizaciones. Actualizado para colecciones - * genéricas de java 1.5. - * - * @author M. Fowler y Carlos López - * @version 1.1 - * @see java.io.File - * - */ - -public class Movie { - public static final int CHILDRENS = 2; - public static final int REGULAR = 0; - public static final int NEW_RELEASE = 1; - - private String _title; - private int _priceCode; - - public Movie(String title, int priceCode) { - _title = title; - _priceCode = priceCode; - } - - public int getPriceCode() { - return _priceCode; - } - - public void setPriceCode(int arg) { - _priceCode = arg; - } - - public String getTitle() { - return _title; - } -} +package ubu.gii.dass.refactoring; +/** + * Tema Refactorizaciones + * + * Ejemplo de aplicación de refactorizaciones. Actualizado para colecciones + * genéricas de java 1.5. + * + * @author M. Fowler y Carlos López + * @version 1.1 + * @see java.io.File + * + */ + +public class Movie { + public static final int CHILDRENS = 2; + public static final int REGULAR = 0; + public static final int NEW_RELEASE = 1; + + private String _title; + private int _priceCode; + + public Movie(String title, int priceCode) { + _title = title; + _priceCode = priceCode; + } + + public int getPriceCode() { + return _priceCode; + } + + public void setPriceCode(int arg) { + _priceCode = arg; + } + + public String getTitle() { + return _title; + } +} diff --git a/src/ubu/gii/dass/refactoring/Rental.java b/src/main/java/com/ivanfpardo/refactoring/Rental.java similarity index 94% rename from src/ubu/gii/dass/refactoring/Rental.java rename to src/main/java/com/ivanfpardo/refactoring/Rental.java index 265c5fca..c07466c8 100644 --- a/src/ubu/gii/dass/refactoring/Rental.java +++ b/src/main/java/com/ivanfpardo/refactoring/Rental.java @@ -1,30 +1,30 @@ -package ubu.gii.dass.refactoring; -/** - * Tema Refactorizaciones - * - * Ejemplo de aplicación de refactorizaciones. Actualizado para colecciones - * genéricas de java 1.5. - * - * @author M. Fowler y Carlos López - * @version 1.1 - * @see java.io.File - * - */ -public class Rental { - private Movie _movie; - private int _daysRented; - - public Rental(Movie movie, int daysRented) { - _movie = movie; - _daysRented = daysRented; - } - - public int getDaysRented() { - return _daysRented; - } - - public Movie getMovie() { - return _movie; - } - -} +package ubu.gii.dass.refactoring; +/** + * Tema Refactorizaciones + * + * Ejemplo de aplicación de refactorizaciones. Actualizado para colecciones + * genéricas de java 1.5. + * + * @author M. Fowler y Carlos López + * @version 1.1 + * @see java.io.File + * + */ +public class Rental { + private Movie _movie; + private int _daysRented; + + public Rental(Movie movie, int daysRented) { + _movie = movie; + _daysRented = daysRented; + } + + public int getDaysRented() { + return _daysRented; + } + + public Movie getMovie() { + return _movie; + } + +} diff --git a/src/ubu/gii/dass/refactoring/VideoClubAplicacion.java b/src/main/java/com/ivanfpardo/refactoring/VideoClubAplicacion.java similarity index 95% rename from src/ubu/gii/dass/refactoring/VideoClubAplicacion.java rename to src/main/java/com/ivanfpardo/refactoring/VideoClubAplicacion.java index 45dd9bf1..8e926f93 100644 --- a/src/ubu/gii/dass/refactoring/VideoClubAplicacion.java +++ b/src/main/java/com/ivanfpardo/refactoring/VideoClubAplicacion.java @@ -1,23 +1,23 @@ -package ubu.gii.dass.refactoring; -public class VideoClubAplicacion { - - public static void main(String[] arg) { - Movie m1 = new Movie("Sky Captain", 1); - Movie m3 = new Movie("Accion Mutante", 0); - Movie m4 = new Movie("Hermano Oso", 2); - - Customer c1 = new Customer("Manuel"); - - Rental r1 = new Rental(m1, 5); - Rental r2 = new Rental(m3, 1); - Rental r3 = new Rental(m4, 10); - - c1.addRental(r1); - c1.addRental(r2); - c1.addRental(r3); - - System.out.println(c1.statement()); - - } - +package ubu.gii.dass.refactoring; +public class VideoClubAplicacion { + + public static void main(String[] arg) { + Movie m1 = new Movie("Sky Captain", 1); + Movie m3 = new Movie("Accion Mutante", 0); + Movie m4 = new Movie("Hermano Oso", 2); + + Customer c1 = new Customer("Manuel"); + + Rental r1 = new Rental(m1, 5); + Rental r2 = new Rental(m3, 1); + Rental r3 = new Rental(m4, 10); + + c1.addRental(r1); + c1.addRental(r2); + c1.addRental(r3); + + System.out.println(c1.statement()); + + } + } \ No newline at end of file diff --git a/src/ubu/gii/dass/refactoring/VideoClubTest.java b/src/test/java/com/ivanfpardo/refactoring/VideoClubTest.java similarity index 95% rename from src/ubu/gii/dass/refactoring/VideoClubTest.java rename to src/test/java/com/ivanfpardo/refactoring/VideoClubTest.java index 82205d33..84f47cd3 100644 --- a/src/ubu/gii/dass/refactoring/VideoClubTest.java +++ b/src/test/java/com/ivanfpardo/refactoring/VideoClubTest.java @@ -1,59 +1,59 @@ -package ubu.gii.dass.refactoring; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * Tema Refactorizaciones - * - * Ejemplo de aplicación de refactorizaciones. Actualizado para colecciones - * genéricas de java 1.5 - * - * @author M. Fowler y Carlos L�pez - * @version 1.1 - - * - */ -public class VideoClubTest { - protected Movie m0, m11, m12, m2; - protected Customer c1; - - @Before - public void setUp() { - m11 = new Movie("Sky Captain", 1); - m12 = new Movie("Alejandro Magno", 1); - m0 = new Movie("Accion Mutante", 0); - m2 = new Movie("Hermano Oso", 2); - - c1 = new Customer("Manuel"); - } - - @After - public void tearDown() throws Exception {} - - @Test - public void testAlquiler() { - - Rental r1 = new Rental(m11, 5); - Rental r2 = new Rental(m0, 1); - Rental r3 = new Rental(m2, 10); - - c1.addRental(r1); - c1.addRental(r2); - c1.addRental(r3); - - String salida = c1.statement(); - - String salidaEsperada = new String("Rental Record for Manuel\n" - + "\tSky Captain\t15.0\n" + "\tAccion Mutante\t2.0\n" - + "\tHermano Oso\t12.0\n" + "Amount owed is 29.0\n" - + "You earned 4 frequent renter points"); - - assertTrue("Calcula mal el alquiler", salidaEsperada.equals(salida)); - - } - -} +package ubu.gii.dass.refactoring; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tema Refactorizaciones + * + * Ejemplo de aplicación de refactorizaciones. Actualizado para colecciones + * genéricas de java 1.5 + * + * @author M. Fowler y Carlos L�pez + * @version 1.1 + + * + */ +public class VideoClubTest { + protected Movie m0, m11, m12, m2; + protected Customer c1; + + @Before + public void setUp() { + m11 = new Movie("Sky Captain", 1); + m12 = new Movie("Alejandro Magno", 1); + m0 = new Movie("Accion Mutante", 0); + m2 = new Movie("Hermano Oso", 2); + + c1 = new Customer("Manuel"); + } + + @After + public void tearDown() throws Exception {} + + @Test + public void testAlquiler() { + + Rental r1 = new Rental(m11, 5); + Rental r2 = new Rental(m0, 1); + Rental r3 = new Rental(m2, 10); + + c1.addRental(r1); + c1.addRental(r2); + c1.addRental(r3); + + String salida = c1.statement(); + + String salidaEsperada = new String("Rental Record for Manuel\n" + + "\tSky Captain\t15.0\n" + "\tAccion Mutante\t2.0\n" + + "\tHermano Oso\t12.0\n" + "Amount owed is 29.0\n" + + "You earned 4 frequent renter points"); + + assertTrue("Calcula mal el alquiler", salidaEsperada.equals(salida)); + + } + +} From b84f25279c1545d065d6b9d3cade4a4489ae892a Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:32:57 +0200 Subject: [PATCH 15/21] test 6 pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 71bf9aee..50ca6cea 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ivanfpardo refactoring-fowler-example - 1.0-SNAPSHOT + 1.0-SNAPSHOT https://github.com/IVANFPARDO/refactoring-fowler-example From 3dc245c231a74ccb1c888c2b69d577d24fc7cdf7 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:36:28 +0200 Subject: [PATCH 16/21] =?UTF-8?q?a=C3=B1adir=20dependencias=20Junit=20en?= =?UTF-8?q?=20pom.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 50ca6cea..e577e990 100644 --- a/pom.xml +++ b/pom.xml @@ -6,8 +6,7 @@ com.ivanfpardo refactoring-fowler-example - 1.0-SNAPSHOT - https://github.com/IVANFPARDO/refactoring-fowler-example + 1.0-SNAPSHOT UTF-8 @@ -15,8 +14,19 @@ 11 + + + + junit + junit + 4.13.2 + test + + + + org.sonarsource.scanner.maven sonar-maven-plugin @@ -25,3 +35,4 @@ + From 1a1d25e18126c1b5e8313d99ea06b6d6bfaa579a Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:41:41 +0200 Subject: [PATCH 17/21] =?UTF-8?q?a=C3=B1adir=20cobertura=20jacoco=20en=20?= =?UTF-8?q?=20sonarcloud.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sonarcloud.yml | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 409d0476..18a8648b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -3,29 +3,31 @@ name: Build and analyze with SonarCloud on: push: branches: + - main - master pull_request: types: [opened, synchronize, reopened] branches: + - main - master jobs: build: - name: Build and SonarCloud Analysis + name: Build and analyze runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '17' + java-version: 17 - - name: Cache Maven packages - uses: actions/cache@v3 + - name: Cache local Maven repository + uses: actions/cache@v4 with: path: ~/.m2 key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} @@ -34,6 +36,8 @@ jobs: - name: Build and analyze env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn clean verify sonar:sonar -Dsonar.projectKey=IVANFPARDO_refactoring-fowler-example -Dsonar.organization=ivanfpardo -Dsonar.host.url=https://sonarcloud.io - - + run: mvn clean verify sonar:sonar \ + -Dsonar.projectKey=IVANFPARDO_refactoring-fowler-example \ + -Dsonar.organization=ivanfpardo \ + -Dsonar.host.url=https://sonarcloud.io \ + -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml From 5b0e21835106e0974588eb58ba882d58864b41dd Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:42:20 +0200 Subject: [PATCH 18/21] actualizar pom.xml con jacoco --- pom.xml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e577e990..ba65644b 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,28 @@ - + + + org.jacoco + jacoco-maven-plugin + 0.8.11 + + + + prepare-agent + + + + report + prepare-package + + report + + + + + + org.sonarsource.scanner.maven sonar-maven-plugin From d6539213fae7cfc93d7b29941b8e0fc3fad17d1d Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:44:53 +0200 Subject: [PATCH 19/21] corregir mvn clean sonarcloud.yml --- .github/workflows/sonarcloud.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 18a8648b..e9e1cc50 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -36,8 +36,5 @@ jobs: - name: Build and analyze env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn clean verify sonar:sonar \ - -Dsonar.projectKey=IVANFPARDO_refactoring-fowler-example \ - -Dsonar.organization=ivanfpardo \ - -Dsonar.host.url=https://sonarcloud.io \ - -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml + run: mvn clean verify sonar:sonar -Dsonar.projectKey=IVANFPARDO_refactoring-fowler-example -Dsonar.organization=ivanfpardo -Dsonar.host.url=https://sonarcloud.io -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml + From 7ecc5034fba9ade924f4dffca8295299734f2328 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:50:14 +0200 Subject: [PATCH 20/21] =?UTF-8?q?modificaci=C3=B3n=20pom.xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index ba65644b..eed09437 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,7 @@ - + junit junit @@ -26,33 +26,34 @@ - + + + org.sonarsource.scanner.maven + sonar-maven-plugin + 3.9.1.2184 + + + org.jacoco jacoco-maven-plugin 0.8.11 + prepare-agent prepare-agent report - prepare-package + verify report - - - - org.sonarsource.scanner.maven - sonar-maven-plugin - 3.9.1.2184 - From 13e94534d4b4cc5d6d334f858d9977e61de9b625 Mon Sep 17 00:00:00 2001 From: IVANFPARDO Date: Mon, 12 May 2025 20:52:15 +0200 Subject: [PATCH 21/21] actualizar jacoco sonarcloud.yml --- .github/workflows/sonarcloud.yml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index e9e1cc50..b06ef204 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -3,12 +3,10 @@ name: Build and analyze with SonarCloud on: push: branches: - - main - master pull_request: types: [opened, synchronize, reopened] branches: - - main - master jobs: @@ -18,20 +16,27 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Set up JDK 17 - uses: actions/setup-java@v4 + uses: actions/setup-java@v3 with: - distribution: 'temurin' java-version: 17 + distribution: 'temurin' + + - name: Cache SonarCloud packages + uses: actions/cache@v3 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar - - name: Cache local Maven repository - uses: actions/cache@v4 + - name: Cache Maven packages + uses: actions/cache@v3 with: path: ~/.m2 - key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-maven + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 - name: Build and analyze env: