-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ActionLog> { | ||
|
||
@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<Arguments> provideGetterParameters() { | ||
return getParameterStream(); | ||
} | ||
|
||
protected static Stream<Arguments> provideSetterParameters() { | ||
return getParameterStream(); | ||
} | ||
|
||
private static Stream<Arguments> getParameterStream() { | ||
return Stream.of( | ||
Arguments.of("submissionStatus", new SubmissionStatus()), | ||
Arguments.of("user", new User()), | ||
Arguments.of("actionDate", Calendar.getInstance()), | ||
Arguments.of("entry", "value") | ||
); | ||
} | ||
|
||
} |