Skip to content

Instantly share code, notes, and snippets.

@codethereforam
Created December 28, 2021 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codethereforam/89ff3460fa95be45f755cf6dc52d428e to your computer and use it in GitHub Desktop.
Save codethereforam/89ff3460fa95be45f755cf6dc52d428e to your computer and use it in GitHub Desktop.
unit test mock redis
@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