From c44d92f8d6992454549a32b6b5652d2735b4bc64 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Nov 2024 19:49:49 +0100 Subject: [PATCH] Cambios para mejora de codigo --- .../src/main/java/es/unican/gasolineras/common/Filtros.java | 4 +++- .../src/main/java/es/unican/gasolineras/common/Tiempo.java | 5 +++++ .../src/main/java/es/unican/gasolineras/common/Utils.java | 4 ++++ .../es/unican/gasolineras/injection/RepositoriesModule.java | 5 +++++ .../main/java/es/unican/gasolineras/model/Gasolinera.java | 4 ---- .../es/unican/gasolineras/repository/GasolinerasService.java | 4 ++++ .../java/es/unican/gasolineras/repository/ICallBack.java | 1 - .../app/src/test/java/es/unican/gasolineras/FiltrosTest.java | 2 +- .../test/java/es/unican/gasolineras/MainPresenterTest.java | 1 - .../app/src/test/java/es/unican/gasolineras/OrdenarTest.java | 1 - 10 files changed, 22 insertions(+), 9 deletions(-) diff --git a/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Filtros.java b/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Filtros.java index 41e059e..036fe4b 100644 --- a/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Filtros.java +++ b/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Filtros.java @@ -17,7 +17,7 @@ public List filtrarPorProvinciaYMunicipio(List gasoliner List resultado = new ArrayList<>(); if (gasolineras.isEmpty()) { - return null; + return resultado; } if (provincia != null && municipio != null) { @@ -152,6 +152,8 @@ public List filtrarPorCombustibles(List gasolineras, Lis anhadida = true; } break; + default: + break; } } } diff --git a/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Tiempo.java b/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Tiempo.java index 4e80832..daa9041 100644 --- a/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Tiempo.java +++ b/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Tiempo.java @@ -5,6 +5,11 @@ public class Tiempo { + + + private Tiempo() { + throw new UnsupportedOperationException("Cannot instantiate Tiempo class"); + } /** * Obtiene la hora actual * @return la hora actual diff --git a/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Utils.java b/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Utils.java index 7cee425..6d0993c 100644 --- a/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Utils.java +++ b/AndroidProject/app/src/main/java/es/unican/gasolineras/common/Utils.java @@ -20,6 +20,10 @@ * Utility methods that may be used by several classes */ public class Utils { + + private Utils() { + throw new UnsupportedOperationException("Cannot instantiate Utils class"); + } /** * Parses a list of gas stations from a json resource file. * The json must contain a serialized GasolinerasResponse object. diff --git a/AndroidProject/app/src/main/java/es/unican/gasolineras/injection/RepositoriesModule.java b/AndroidProject/app/src/main/java/es/unican/gasolineras/injection/RepositoriesModule.java index 258945c..4a826d6 100644 --- a/AndroidProject/app/src/main/java/es/unican/gasolineras/injection/RepositoriesModule.java +++ b/AndroidProject/app/src/main/java/es/unican/gasolineras/injection/RepositoriesModule.java @@ -20,6 +20,11 @@ @InstallIn(ActivityComponent.class) public abstract class RepositoriesModule { + + private RepositoriesModule() { + throw new UnsupportedOperationException("Cannot instantiate RepositoriesModule class"); + } + @Provides public static IGasolinerasRepository provideRepository() { return GasolinerasRepository.INSTANCE; diff --git a/AndroidProject/app/src/main/java/es/unican/gasolineras/model/Gasolinera.java b/AndroidProject/app/src/main/java/es/unican/gasolineras/model/Gasolinera.java index 4050a2d..2606297 100644 --- a/AndroidProject/app/src/main/java/es/unican/gasolineras/model/Gasolinera.java +++ b/AndroidProject/app/src/main/java/es/unican/gasolineras/model/Gasolinera.java @@ -4,11 +4,7 @@ import com.google.gson.annotations.SerializedName; -import es.unican.gasolineras.common.DataAccessException; -import es.unican.gasolineras.common.Horario; import org.parceler.Parcel; -import java.util.Date; -import java.util.Calendar; import lombok.Getter; import lombok.Setter; diff --git a/AndroidProject/app/src/main/java/es/unican/gasolineras/repository/GasolinerasService.java b/AndroidProject/app/src/main/java/es/unican/gasolineras/repository/GasolinerasService.java index 72ac52a..73e2aaf 100644 --- a/AndroidProject/app/src/main/java/es/unican/gasolineras/repository/GasolinerasService.java +++ b/AndroidProject/app/src/main/java/es/unican/gasolineras/repository/GasolinerasService.java @@ -20,6 +20,10 @@ */ public class GasolinerasService { + private GasolinerasService() { + throw new UnsupportedOperationException("Cannot instantiate GasolinerasService class"); + } + /** Open Charge Map API base URL*/ final static String BASE_URL = "https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/"; diff --git a/AndroidProject/app/src/main/java/es/unican/gasolineras/repository/ICallBack.java b/AndroidProject/app/src/main/java/es/unican/gasolineras/repository/ICallBack.java index 51b98e8..51f42ba 100644 --- a/AndroidProject/app/src/main/java/es/unican/gasolineras/repository/ICallBack.java +++ b/AndroidProject/app/src/main/java/es/unican/gasolineras/repository/ICallBack.java @@ -2,7 +2,6 @@ import java.util.List; -import es.unican.gasolineras.model.Gasolinera; /** * The callback used by the repository to asynchronously retrieve gas stations. diff --git a/AndroidProject/app/src/test/java/es/unican/gasolineras/FiltrosTest.java b/AndroidProject/app/src/test/java/es/unican/gasolineras/FiltrosTest.java index 328b905..c6f0d1b 100644 --- a/AndroidProject/app/src/test/java/es/unican/gasolineras/FiltrosTest.java +++ b/AndroidProject/app/src/test/java/es/unican/gasolineras/FiltrosTest.java @@ -153,7 +153,7 @@ public void testUD1H() { @Test public void testUD1I() { List resultado = filtros.filtrarPorProvinciaYMunicipio(Collections.emptyList(), "Cantabria", "Santander"); - assertNull(resultado); + assertEquals(resultado, Collections.emptyList()); } diff --git a/AndroidProject/app/src/test/java/es/unican/gasolineras/MainPresenterTest.java b/AndroidProject/app/src/test/java/es/unican/gasolineras/MainPresenterTest.java index 6eff116..e01b3cf 100644 --- a/AndroidProject/app/src/test/java/es/unican/gasolineras/MainPresenterTest.java +++ b/AndroidProject/app/src/test/java/es/unican/gasolineras/MainPresenterTest.java @@ -21,7 +21,6 @@ import es.unican.gasolineras.activities.main.IMainContract; import es.unican.gasolineras.activities.main.MainPresenter; -import es.unican.gasolineras.common.DataAccessException; import es.unican.gasolineras.common.IFiltros; import es.unican.gasolineras.utils.MockRepositories; import es.unican.gasolineras.repository.IGasolinerasRepository; diff --git a/AndroidProject/app/src/test/java/es/unican/gasolineras/OrdenarTest.java b/AndroidProject/app/src/test/java/es/unican/gasolineras/OrdenarTest.java index f6b51d1..999d754 100644 --- a/AndroidProject/app/src/test/java/es/unican/gasolineras/OrdenarTest.java +++ b/AndroidProject/app/src/test/java/es/unican/gasolineras/OrdenarTest.java @@ -14,7 +14,6 @@ import es.unican.gasolineras.activities.main.IMainContract; import es.unican.gasolineras.activities.main.MainPresenter; -import es.unican.gasolineras.common.DataAccessException; import es.unican.gasolineras.model.Gasolinera; import es.unican.gasolineras.repository.IGasolinerasRepository;