@Test public void testGetAlarmStatus() { Vertex vertex = new TestVertex(); EasyMock.expect(m_alarmDao.findMatching(EasyMock.notNull(Criteria.class))).andReturn(createNormalStatusList()); EasyMock.replay(m_alarmDao); Status vertexStatus = m_statusProvider.getStatusForVertex(vertex); String computeStatus = vertexStatus.computeStatus(); assertTrue(computeStatus.equals("indeterminate")); EasyMock.verify(m_alarmDao); }
@Override public Status getStatusForVertex(VertexRef vertexRef) { if(vertexRef.getNamespace().equals("nodes")) { if(isGroup(vertexRef) && getVertexProvider() != null) { return getStatusForGroup(vertexRef); } else { try { int nodeId = Integer.valueOf(vertexRef.getId()); CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class); builder.alias("node", "node"); builder.eq("node.id", nodeId); builder.ge("severity", OnmsSeverity.WARNING); builder.orderBy("severity").desc(); builder.limit(1); return getStatusForCriteria(builder); }catch(NumberFormatException e) { return createIndeterminateStatus(); } } } else { return createIndeterminateStatus(); } }
AlarmStatusProvider implements StatusProvider { @Override public Status getStatusForVertex(VertexRef vertexRef) { if(vertexRef.getNamespace().equals("nodes")) { if(isGroup(vertexRef) && getVertexProvider() != null) { return getStatusForGroup(vertexRef); } else { try { int nodeId = Integer.valueOf(vertexRef.getId()); CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class); builder.alias("node", "node"); builder.eq("node.id", nodeId); builder.ge("severity", OnmsSeverity.WARNING); builder.orderBy("severity").desc(); builder.limit(1); return getStatusForCriteria(builder); }catch(NumberFormatException e) { return createIndeterminateStatus(); } } } else { return createIndeterminateStatus(); } } }
AlarmStatusProvider implements StatusProvider { @Override public Status getStatusForVertex(VertexRef vertexRef) { if(vertexRef.getNamespace().equals("nodes")) { if(isGroup(vertexRef) && getVertexProvider() != null) { return getStatusForGroup(vertexRef); } else { try { int nodeId = Integer.valueOf(vertexRef.getId()); CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class); builder.alias("node", "node"); builder.eq("node.id", nodeId); builder.ge("severity", OnmsSeverity.WARNING); builder.orderBy("severity").desc(); builder.limit(1); return getStatusForCriteria(builder); }catch(NumberFormatException e) { return createIndeterminateStatus(); } } } else { return createIndeterminateStatus(); } }  }
AlarmStatusProvider implements StatusProvider { @Override public Status getStatusForVertex(VertexRef vertexRef) { if(vertexRef.getNamespace().equals("nodes")) { if(isGroup(vertexRef) && getVertexProvider() != null) { return getStatusForGroup(vertexRef); } else { try { int nodeId = Integer.valueOf(vertexRef.getId()); CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class); builder.alias("node", "node"); builder.eq("node.id", nodeId); builder.ge("severity", OnmsSeverity.WARNING); builder.orderBy("severity").desc(); builder.limit(1); return getStatusForCriteria(builder); }catch(NumberFormatException e) { return createIndeterminateStatus(); } } } else { return createIndeterminateStatus(); } }  VertexProvider getVertexProvider(); void setVertexProvider(VertexProvider vertexProvider); AlarmDao getAlarmDao(); void setAlarmDao(AlarmDao alarmDao); @Override Status getStatusForVertex(VertexRef vertexRef); @Override Collection<Status> getStatusForVertices(Collection<VertexRef> vertices); @Override String getNamespace(); }
AlarmStatusProvider implements StatusProvider { @Override public Status getStatusForVertex(VertexRef vertexRef) { if(vertexRef.getNamespace().equals("nodes")) { if(isGroup(vertexRef) && getVertexProvider() != null) { return getStatusForGroup(vertexRef); } else { try { int nodeId = Integer.valueOf(vertexRef.getId()); CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class); builder.alias("node", "node"); builder.eq("node.id", nodeId); builder.ge("severity", OnmsSeverity.WARNING); builder.orderBy("severity").desc(); builder.limit(1); return getStatusForCriteria(builder); }catch(NumberFormatException e) { return createIndeterminateStatus(); } } } else { return createIndeterminateStatus(); } }  VertexProvider getVertexProvider(); void setVertexProvider(VertexProvider vertexProvider); AlarmDao getAlarmDao(); void setAlarmDao(AlarmDao alarmDao); @Override Status getStatusForVertex(VertexRef vertexRef); @Override Collection<Status> getStatusForVertices(Collection<VertexRef> vertices); @Override String getNamespace();  }