package com.mattrixwv.project_euler.problems; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.List; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import com.mattrixwv.project_euler.exceptions.Unsolved; public class TestProblem21 extends ProblemBaseTest{ @InjectMocks private Problem21 problem; static{ description = "Evaluate the sum of all the amicable numbers under 10000"; result = String.format("All amicable numbers less than 10000 are%n220%n284%n1184%n1210%n2620%n2924%n5020%n5564%n6232%n6368%nThe sum of all of these amicable numbers is 31626"); } @Test @Order(1) @Override public void testDescription(){ super.testDescription(problem); } @Test @Order(2) @Override public void testSolve(){ assertThrows(Unsolved.class, () -> { problem.getAmicable(); }); assertThrows(Unsolved.class, () -> { problem.getSum(); }); super.testSolve(problem); //Verify result assertEquals(List.of(220, 284, 1184, 1210, 2620, 2924, 5020, 5564, 6232, 6368), problem.getAmicable()); assertEquals(31626, problem.getSum()); } @Test @Order(3) @Override public void testReset(){ super.testReset(problem); } }