Content of file GameMemoryCapacityTest.java
package de.fhdw.gaming.ipspiel23.memory;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/**
 * Tests for the {@link GameMemoryCapacity} class.
 */
public class GameMemoryCapacityTest {
    /**
     * Tests the {@link GameMemoryCapacity#unlimited()} method.
     */
    @Test
    void testUnlimited() {
        final IGameMemoryCapacity capacity = GameMemoryCapacity.unlimited();
        assertTrue(capacity.isUnlimited());
        assertFalse(capacity.isDefault());
        assertEquals(-1, capacity.getCapacity());
    }
    /**
     * Tests the {@link GameMemoryCapacity#of(int)} method.
     */
    @Test
    void testOf() {
        final int customCapacity = 10;
        final IGameMemoryCapacity capacity = GameMemoryCapacity.of(customCapacity);
        assertFalse(capacity.isUnlimited());
        assertFalse(capacity.isDefault());
        assertEquals(customCapacity, capacity.getCapacity());
    }
    /**
     * Tests the {@link GameMemoryCapacity#useDefault()} method.
     */
    @Test
    void testUseDefault() {
        final IGameMemoryCapacity capacity = GameMemoryCapacity.useDefault();
        assertFalse(capacity.isUnlimited());
        assertTrue(capacity.isDefault());
        assertEquals(5, capacity.getCapacity());
    }
    /**
     * Tests that an {@link IllegalArgumentException} is thrown when passing an invalid capacity to the
     * {@link GameMemoryCapacity#of(int)} method.
     */
    @Test
    void testInvalidCapacity() {
        final Integer invalidCapacity = -1;
        IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
            GameMemoryCapacity.of(invalidCapacity);
        });
A local variable assigned only once can be declared final.
        
    
        
public class Bar {
    public void foo () {
    String txtA = "a";          // if txtA will not be assigned again it is better to do this:
    final String txtB = "b";
    }
}
        
    
    See PMD documentation.
        assertEquals("Capacity must be greater than or equal to 0", exception.getMessage());
    }
}