Created
December 28, 2021 08:12
-
-
Save codethereforam/89ff3460fa95be45f755cf6dc52d428e to your computer and use it in GitHub Desktop.
unit test mock redis
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
@Slf4j | |
@RunWith(MockitoJUnitRunner.class) | |
public class MockRedisTest { | |
private StringRedisTemplate stringRedisTemplate; | |
@Before | |
public void setUp() { | |
stringRedisTemplate = Mockito.mock(StringRedisTemplate.class); | |
ValueOperations valueOperations = Mockito.mock(ValueOperations.class); | |
when(stringRedisTemplate.opsForValue()).thenReturn(valueOperations); | |
when(stringRedisTemplate.opsForValue().get(any())).thenReturn(""); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment