diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml
new file mode 100644
index 00000000..b06ef204
--- /dev/null
+++ b/.github/workflows/sonarcloud.yml
@@ -0,0 +1,45 @@
+name: Build and analyze with SonarCloud
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ types: [opened, synchronize, reopened]
+ branches:
+ - master
+
+jobs:
+ build:
+ name: Build and analyze
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v3
+
+ - name: Set up JDK 17
+ uses: actions/setup-java@v3
+ with:
+ 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 Maven packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2
+
+ - 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
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 00000000..eed09437
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,60 @@
+
+ 4.0.0
+
+ com.ivanfpardo
+ refactoring-fowler-example
+ 1.0-SNAPSHOT
+
+
+ UTF-8
+ 11
+ 11
+
+
+
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+
+
+
+
+
+ org.sonarsource.scanner.maven
+ sonar-maven-plugin
+ 3.9.1.2184
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.11
+
+
+ prepare-agent
+
+ prepare-agent
+
+
+
+ report
+ verify
+
+ report
+
+
+
+
+
+
+
+
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));
+
+ }
+
+}