-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for supplying a version timestamp for the 'map-sid' funct…
…ion (#20) * Initial setup for version timestamp * Removed SidMapperMock and replace by mockito mocks * Release dapla-dlp-pseudo-func --------- Co-authored-by: Michael Moen Allport <[email protected]>
- Loading branch information
1 parent
f661c6c
commit a2bc3f6
Showing
3 changed files
with
46 additions
and
1 deletion.
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
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
38 changes: 38 additions & 0 deletions
38
src/test/java/no/ssb/dlp/pseudo/core/func/MapFuncTest.java
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,38 @@ | ||
package no.ssb.dlp.pseudo.core.func; | ||
|
||
import no.ssb.dapla.dlp.pseudo.func.PseudoFunc; | ||
import no.ssb.dapla.dlp.pseudo.func.PseudoFuncConfig; | ||
import no.ssb.dapla.dlp.pseudo.func.PseudoFuncFactory; | ||
import no.ssb.dapla.dlp.pseudo.func.PseudoFuncInput; | ||
import no.ssb.dapla.dlp.pseudo.func.map.MapFunc; | ||
import no.ssb.dapla.dlp.pseudo.func.map.Mapper; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.ArgumentCaptor; | ||
|
||
import java.util.Map; | ||
|
||
import static org.mockito.Mockito.*; | ||
|
||
public class MapFuncTest { | ||
private PseudoFunc f(String funcDecl) { | ||
PseudoFuncConfig config = PseudoFuncConfigFactory.get(funcDecl); | ||
return PseudoFuncFactory.create(config); | ||
} | ||
|
||
@Test | ||
void mapFuncWithTimestamp() { | ||
final Mapper mockMapper = mock(Mapper.class); | ||
try (var mapFunc = mockStatic(MapFunc.class)) { | ||
mapFunc.when(() -> MapFunc.loadMapper()).thenReturn(mockMapper); | ||
String funcDeclStr = "map-sid(keyId=1284924461, versionTimestamp=test)"; | ||
PseudoFunc func = f(funcDeclStr); | ||
func.init(PseudoFuncInput.of("50607080901")); | ||
} | ||
// Check that the mockMapper has received the versionTimestamp | ||
ArgumentCaptor<Map> argumentsCaptured = ArgumentCaptor.forClass(Map.class); | ||
verify(mockMapper).setConfig(argumentsCaptured.capture()); | ||
assert argumentsCaptured.getValue().containsKey("versionTimestamp"); | ||
// Check that the init method was called | ||
verify(mockMapper).init(eq("50607080901")); | ||
} | ||
} |