diff --git a/src/test/java/org/tdl/vireo/model/ActionLogTest.java b/src/test/java/org/tdl/vireo/model/ActionLogTest.java new file mode 100644 index 000000000..4e3c14f4f --- /dev/null +++ b/src/test/java/org/tdl/vireo/model/ActionLogTest.java @@ -0,0 +1,68 @@ +package org.tdl.vireo.model; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Calendar; +import java.util.stream.Stream; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.provider.Arguments; +import org.mockito.InjectMocks; +import org.springframework.test.util.ReflectionTestUtils; + +public class ActionLogTest extends AbstractModelTest { + + @InjectMocks + private ActionLog actionLog; + + /** + * The getPrivate() does not work via getParameterStream() and is manually tested here. + * + * This may be because the method is called "isPrivateFlag()" rather than "getPrivateFlag()". + */ + @Test + public void testGetSettings() { + boolean value = false; + + ReflectionTestUtils.setField(actionLog, "privateFlag", value); + + assertEquals(value, actionLog.isPrivateFlag(), GETTER_MESSAGE); + } + + /** + * The privateFlag() does not work via getParameterStream() and is manually tested here. + */ + @Test + public void testSetSettings() { + boolean value = false; + + // Set the flag to something other than false to confirm setter works. + ReflectionTestUtils.setField(actionLog, "privateFlag", true); + + actionLog.setPrivateFlag(value); + + assertEquals(value, ReflectionTestUtils.getField(getInstance(), "privateFlag"), SETTER_MESSAGE); + } + + @Override + protected ActionLog getInstance() { + return actionLog; + } + + protected static Stream provideGetterParameters() { + return getParameterStream(); + } + + protected static Stream provideSetterParameters() { + return getParameterStream(); + } + + private static Stream getParameterStream() { + return Stream.of( + Arguments.of("submissionStatus", new SubmissionStatus()), + Arguments.of("user", new User()), + Arguments.of("actionDate", Calendar.getInstance()), + Arguments.of("entry", "value") + ); + } + +}