@Test public void shouldCallSessionCheckOnEvent() throws ADKException { SIFDataObject mockSifDataObject = createMockSifDataObject(); Event mockEvent = createMockSifEvent(false, mockSifDataObject); Zone mockZone = createMockZone(); MessageInfo mockInfo = createMockInfo(); subscriber.onEvent(mockEvent, mockZone, mockInfo); Mockito.verify(mockSlcInterface, Mockito.times(1)).sessionCheck(); }
@Override public void onEvent(Event event, Zone zone, MessageInfo info) throws ADKException { LOG.info("Received event:\n" + "\tEvent: " + event.getActionString() + "\n" + "\tZone: " + zone.getZoneId() + "\n" + "\tInfo: " + info); SIFDataObject sifData = inspectAndDestroyEvent(event); boolean tokenChecked = false; String token = slcInterface.sessionCheck(); if (token != null && token.length() > 0) { tokenChecked = true; LOG.info("Successfully executed session check with token " + token); } else { LOG.info("Session check failed"); } if (sifData != null && tokenChecked && event.getAction() != null) { List<SliEntity> entities = translationManager.translate(sifData, zone.getZoneId()); Entity matchedEntity; switch (event.getAction()) { case ADD: for (SliEntity sliEntity : entities) { matchedEntity = findCombiningEntity(sliEntity, zone.getZoneId()); if (matchedEntity != null) { changeEntity(sifData, sliEntity, zone.getZoneId(), matchedEntity); sifIdResolver.putSliGuid(sifData.getRefId(), matchedEntity.getEntityType(), matchedEntity.getId(), zone.getZoneId()); } else { addEntity(sifData, zone.getZoneId(), sliEntity); } } break; case CHANGE: List<Entity> matchedEntities = sifIdResolver.getSliEntityList(sifData.getRefId(), zone.getZoneId()); if (entities == null || entities.isEmpty()) { LOG.warn("Null or empty translated SIF entities: " + entities); } else if (matchedEntities == null || matchedEntities.isEmpty()) { LOG.warn("Null or empty SIF entities (no entity found to update): " + matchedEntities); } else { for (SliEntity sliEntity : entities) { for (Entity e : matchedEntities) { if (sliEntity.entityType().equals(e.getEntityType())) { changeEntity(sifData, sliEntity, zone.getZoneId(), e); } } } } break; case UNDEFINED: default: LOG.error("Unsupported SIF Action: " + event.getAction()); break; } } }
SifSubscriber implements Subscriber { @Override public void onEvent(Event event, Zone zone, MessageInfo info) throws ADKException { LOG.info("Received event:\n" + "\tEvent: " + event.getActionString() + "\n" + "\tZone: " + zone.getZoneId() + "\n" + "\tInfo: " + info); SIFDataObject sifData = inspectAndDestroyEvent(event); boolean tokenChecked = false; String token = slcInterface.sessionCheck(); if (token != null && token.length() > 0) { tokenChecked = true; LOG.info("Successfully executed session check with token " + token); } else { LOG.info("Session check failed"); } if (sifData != null && tokenChecked && event.getAction() != null) { List<SliEntity> entities = translationManager.translate(sifData, zone.getZoneId()); Entity matchedEntity; switch (event.getAction()) { case ADD: for (SliEntity sliEntity : entities) { matchedEntity = findCombiningEntity(sliEntity, zone.getZoneId()); if (matchedEntity != null) { changeEntity(sifData, sliEntity, zone.getZoneId(), matchedEntity); sifIdResolver.putSliGuid(sifData.getRefId(), matchedEntity.getEntityType(), matchedEntity.getId(), zone.getZoneId()); } else { addEntity(sifData, zone.getZoneId(), sliEntity); } } break; case CHANGE: List<Entity> matchedEntities = sifIdResolver.getSliEntityList(sifData.getRefId(), zone.getZoneId()); if (entities == null || entities.isEmpty()) { LOG.warn("Null or empty translated SIF entities: " + entities); } else if (matchedEntities == null || matchedEntities.isEmpty()) { LOG.warn("Null or empty SIF entities (no entity found to update): " + matchedEntities); } else { for (SliEntity sliEntity : entities) { for (Entity e : matchedEntities) { if (sliEntity.entityType().equals(e.getEntityType())) { changeEntity(sifData, sliEntity, zone.getZoneId(), e); } } } } break; case UNDEFINED: default: LOG.error("Unsupported SIF Action: " + event.getAction()); break; } } } }
SifSubscriber implements Subscriber { @Override public void onEvent(Event event, Zone zone, MessageInfo info) throws ADKException { LOG.info("Received event:\n" + "\tEvent: " + event.getActionString() + "\n" + "\tZone: " + zone.getZoneId() + "\n" + "\tInfo: " + info); SIFDataObject sifData = inspectAndDestroyEvent(event); boolean tokenChecked = false; String token = slcInterface.sessionCheck(); if (token != null && token.length() > 0) { tokenChecked = true; LOG.info("Successfully executed session check with token " + token); } else { LOG.info("Session check failed"); } if (sifData != null && tokenChecked && event.getAction() != null) { List<SliEntity> entities = translationManager.translate(sifData, zone.getZoneId()); Entity matchedEntity; switch (event.getAction()) { case ADD: for (SliEntity sliEntity : entities) { matchedEntity = findCombiningEntity(sliEntity, zone.getZoneId()); if (matchedEntity != null) { changeEntity(sifData, sliEntity, zone.getZoneId(), matchedEntity); sifIdResolver.putSliGuid(sifData.getRefId(), matchedEntity.getEntityType(), matchedEntity.getId(), zone.getZoneId()); } else { addEntity(sifData, zone.getZoneId(), sliEntity); } } break; case CHANGE: List<Entity> matchedEntities = sifIdResolver.getSliEntityList(sifData.getRefId(), zone.getZoneId()); if (entities == null || entities.isEmpty()) { LOG.warn("Null or empty translated SIF entities: " + entities); } else if (matchedEntities == null || matchedEntities.isEmpty()) { LOG.warn("Null or empty SIF entities (no entity found to update): " + matchedEntities); } else { for (SliEntity sliEntity : entities) { for (Entity e : matchedEntities) { if (sliEntity.entityType().equals(e.getEntityType())) { changeEntity(sifData, sliEntity, zone.getZoneId(), e); } } } } break; case UNDEFINED: default: LOG.error("Unsupported SIF Action: " + event.getAction()); break; } } }  }
SifSubscriber implements Subscriber { @Override public void onEvent(Event event, Zone zone, MessageInfo info) throws ADKException { LOG.info("Received event:\n" + "\tEvent: " + event.getActionString() + "\n" + "\tZone: " + zone.getZoneId() + "\n" + "\tInfo: " + info); SIFDataObject sifData = inspectAndDestroyEvent(event); boolean tokenChecked = false; String token = slcInterface.sessionCheck(); if (token != null && token.length() > 0) { tokenChecked = true; LOG.info("Successfully executed session check with token " + token); } else { LOG.info("Session check failed"); } if (sifData != null && tokenChecked && event.getAction() != null) { List<SliEntity> entities = translationManager.translate(sifData, zone.getZoneId()); Entity matchedEntity; switch (event.getAction()) { case ADD: for (SliEntity sliEntity : entities) { matchedEntity = findCombiningEntity(sliEntity, zone.getZoneId()); if (matchedEntity != null) { changeEntity(sifData, sliEntity, zone.getZoneId(), matchedEntity); sifIdResolver.putSliGuid(sifData.getRefId(), matchedEntity.getEntityType(), matchedEntity.getId(), zone.getZoneId()); } else { addEntity(sifData, zone.getZoneId(), sliEntity); } } break; case CHANGE: List<Entity> matchedEntities = sifIdResolver.getSliEntityList(sifData.getRefId(), zone.getZoneId()); if (entities == null || entities.isEmpty()) { LOG.warn("Null or empty translated SIF entities: " + entities); } else if (matchedEntities == null || matchedEntities.isEmpty()) { LOG.warn("Null or empty SIF entities (no entity found to update): " + matchedEntities); } else { for (SliEntity sliEntity : entities) { for (Entity e : matchedEntities) { if (sliEntity.entityType().equals(e.getEntityType())) { changeEntity(sifData, sliEntity, zone.getZoneId(), e); } } } } break; case UNDEFINED: default: LOG.error("Unsupported SIF Action: " + event.getAction()); break; } } }  @Override void onEvent(Event event, Zone zone, MessageInfo info); }
SifSubscriber implements Subscriber { @Override public void onEvent(Event event, Zone zone, MessageInfo info) throws ADKException { LOG.info("Received event:\n" + "\tEvent: " + event.getActionString() + "\n" + "\tZone: " + zone.getZoneId() + "\n" + "\tInfo: " + info); SIFDataObject sifData = inspectAndDestroyEvent(event); boolean tokenChecked = false; String token = slcInterface.sessionCheck(); if (token != null && token.length() > 0) { tokenChecked = true; LOG.info("Successfully executed session check with token " + token); } else { LOG.info("Session check failed"); } if (sifData != null && tokenChecked && event.getAction() != null) { List<SliEntity> entities = translationManager.translate(sifData, zone.getZoneId()); Entity matchedEntity; switch (event.getAction()) { case ADD: for (SliEntity sliEntity : entities) { matchedEntity = findCombiningEntity(sliEntity, zone.getZoneId()); if (matchedEntity != null) { changeEntity(sifData, sliEntity, zone.getZoneId(), matchedEntity); sifIdResolver.putSliGuid(sifData.getRefId(), matchedEntity.getEntityType(), matchedEntity.getId(), zone.getZoneId()); } else { addEntity(sifData, zone.getZoneId(), sliEntity); } } break; case CHANGE: List<Entity> matchedEntities = sifIdResolver.getSliEntityList(sifData.getRefId(), zone.getZoneId()); if (entities == null || entities.isEmpty()) { LOG.warn("Null or empty translated SIF entities: " + entities); } else if (matchedEntities == null || matchedEntities.isEmpty()) { LOG.warn("Null or empty SIF entities (no entity found to update): " + matchedEntities); } else { for (SliEntity sliEntity : entities) { for (Entity e : matchedEntities) { if (sliEntity.entityType().equals(e.getEntityType())) { changeEntity(sifData, sliEntity, zone.getZoneId(), e); } } } } break; case UNDEFINED: default: LOG.error("Unsupported SIF Action: " + event.getAction()); break; } } }  @Override void onEvent(Event event, Zone zone, MessageInfo info);  }