Skip to content

Conversation

@CesarRodrigu
Copy link

No description provided.

@clopezno clopezno requested review from clopezno and Copilot March 4, 2025 16:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This pull request updates the project documentation and enhances the test suite for the reusable pool functionality.

  • README.md now includes CI badges, editor credits, and links to test coverage reports.
  • ReusablePoolTest.java is updated with improved tests for pool instance retrieval, acquisition, release, and client usage, and introduces an @AfterEach cleanup method.

Reviewed Changes

File Description
README.md Added CI badges, editor credits, and coverage report links.
src/test/java/ubu/gii/dass/c01/ReusablePoolTest.java Improved tests and added cleanup for reusable pool functionality.

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Co-authored-by: Copilot <[email protected]>
Copy link
Owner

@clopezno clopezno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sugiero mejorar la comprensión sobre conceptos básicos implementación de pruebas: para que sirve @AfterEach, añadir mensajes en los assert que ayuden a mejorar la comprensión en caso de ejecución fallida de la prueba, eliminar las referencias a System.out.println


/*
* Funcionalidad: Se ejecuta después de cada prueba e intenta adquirir todas las instancias reutilizables
* del pool y luego libera nuevas instancias para restablecer el estado del pool.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Este comentario no es necesario.

}
} catch (NotFreeInstanceException e) {
try {
System.out.println("Med" + pool);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No se incluyen System.out.println en los test

@AfterEach
public void despues() {
ReusablePool pool = ReusablePool.getInstance();
System.out.println("Antes" + pool);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No se incluyen System.out.println en los test

try {
while (true) {
pool.acquireReusable();
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El objetivo de @AfterEach es liberar todo lo que se haya reservado en @beforeeach. Esta porción de código no procede.

assertNotNull(pool1);
assertNotNull(pool2);
assertSame(pool1, pool2);
assertEquals(pool1, pool2);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Añadir mensajes descriptivos del caso de prueba en los assert ayuda a mejorar la comprensión en caso de producirse el error detectado por la prueba. Este comentario de revisión intenta mejorar la facilidad de mantenimiento.

public void testAcquireReusable() {

ReusablePool pool = ReusablePool.getInstance();
System.out.println(pool);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No se añade un system.out.println a una caso de prueba

*
*/
public class ReusablePoolTest {
private static final int num = 2;
Copy link
Owner

@clopezno clopezno Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dos comentarios

  1. Por convención de nombres en Java las constantes se escriben en mayúsculas
  2. num no describe con precisión su objetivo, aconsejo renombrar POOL_TAM_MAX

public void testClient() {
assertNotNull(new Client());
assertDoesNotThrow(() -> Client.main(null));
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esta prueba esta fuera del contexto de prueba Reusablepool se debería eliminar de este fichero. Además, Reusable es una implementación de compromiso que no debería ser probada. Entiendo que se ha añadido para conseguir el 100% de cobertura del sistema. Si se quiere eliminar el seguimiento de su cobertura se puede indicar en el fichero de configuración de .codecov.yml añadiendo

  ignore:
  - "src/main/java/ubu/gii/dass/c01/Client.java"
  - "src/main/java/ubu/gii/dass/c01/Reusable.java" 

System.out.println(pool);
try {
for (int i = 0; i < ReusablePoolTest.num; i++) {
pool.acquireReusable();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se necesita probar que pool.acquireReusable() retorna un objeto de Reusable.

Reusable reusable = pool.acquireReusable();
assertNotNull(reusable,"El objeto reusable adquirido no debería ser nulo");
assertTrue(reusable instanceof Reusable, "El objeto adquirido debe ser una instancia de Reusable");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants