Guest User

Untitled

a guest
Nov 19th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. @RunWith(MockitoJUnitRunner.class)
  2. public class IgniteAlertsSoreTest {
  3. @Mock
  4. private Ignite ignite;
  5. @Mock
  6. Cache<String, List<AlertEntry>> cache;
  7. @Mock
  8. IgniteCache IgniteCache;
  9. @InjectMocks
  10. private IgniteAlertsStore igniteAlertsStore;
  11. //simulate the needed behaviour for the mocked ignite cache
  12. @Before
  13. public void setUp() throws Exception {
  14. when(ignite.getOrCreateCache(anyString())).thenReturn(IgniteCache);
  15. List<AlertEntry> entries=new ArrayList<>();
  16. entries.add(AlertEntry.builder().errorCode("errorCode").build());
  17. when(IgniteCache.get(anyString())).thenReturn(entries);
  18. }
  19. @Test
  20. public void getAllAlerts() throws Exception {
  21. assertEquals(igniteAlertsStore.getAlertForServiceId("serviceId").get(0).getErrorCode(),"errorCode");
  22. }
  23.  
  24.  
  25. }
Add Comment
Please, Sign In to add comment