Search in sources :

Example 1 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class PingForConfigurationResponderImplTest method testPingForConfigurationErrors.

@Test
public void testPingForConfigurationErrors() {
    long signatureQueueMeasure = -1;
    long nbrUsersMeasure = -1;
    when(healthCheck.checkDB()).thenReturn(new HealthStatus(-1, false));
    when(healthCheck.checkJMS()).thenReturn(new HealthStatus(-1, false));
    when(healthCheck.checkSignatureQueue()).thenReturn(new HealthStatus(signatureQueueMeasure, false));
    when(healthCheck.checkIntygstjanst()).thenReturn(new HealthStatus(-1, false));
    when(healthCheck.checkPrivatlakarportal()).thenReturn(new HealthStatus(-1, false));
    when(healthCheck.checkUptime()).thenReturn(new HealthStatus(-1, false));
    when(healthCheck.checkNbrOfUsers()).thenReturn(new HealthStatus(nbrUsersMeasure, false));
    PingForConfigurationResponseType res = responder.pingForConfiguration("logicalAddress", new PingForConfigurationType());
    assertNotNull(res);
    assertNotNull(res.getPingDateTime());
    assertEquals(PROJECT_VERSION, res.getVersion());
    assertEquals(BUILD_NUMBER, res.getConfiguration().stream().filter(c -> "buildNumber".equals(c.getName())).findAny().get().getValue());
    assertEquals(BUILD_TIME, res.getConfiguration().stream().filter(c -> "buildTime".equals(c.getName())).findAny().get().getValue());
    assertNotNull(res.getConfiguration().stream().filter(c -> "systemUptime".equals(c.getName())).findAny().get().getValue());
    assertEquals("error", res.getConfiguration().stream().filter(c -> "dbStatus".equals(c.getName())).findAny().get().getValue());
    assertEquals("error", res.getConfiguration().stream().filter(c -> "jmsStatus".equals(c.getName())).findAny().get().getValue());
    assertEquals("no connection", res.getConfiguration().stream().filter(c -> "intygstjanst".equals(c.getName())).findAny().get().getValue());
    assertEquals("no connection", res.getConfiguration().stream().filter(c -> "privatlakarportal".equals(c.getName())).findAny().get().getValue());
    assertEquals("" + signatureQueueMeasure, res.getConfiguration().stream().filter(c -> "signatureQueueSize".equals(c.getName())).findAny().get().getValue());
    assertEquals("" + nbrUsersMeasure, res.getConfiguration().stream().filter(c -> "nbrOfUsers".equals(c.getName())).findAny().get().getValue());
    verify(healthCheck).checkDB();
    verify(healthCheck).checkJMS();
    verify(healthCheck).checkSignatureQueue();
    verify(healthCheck).checkIntygstjanst();
    verify(healthCheck).checkPrivatlakarportal();
    verify(healthCheck).checkUptime();
    verify(healthCheck).checkNbrOfUsers();
}
Also used : PingForConfigurationType(se.riv.itintegration.monitoring.v1.PingForConfigurationType) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) PingForConfigurationResponseType(se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType) Test(org.junit.Test)

Example 2 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class PingForConfigurationResponderImplTest method testPingForConfiguration.

@Test
public void testPingForConfiguration() {
    long signatureQueueMeasure = 3;
    long nbrUsersMeasure = 7;
    when(healthCheck.checkDB()).thenReturn(new HealthStatus(1, true));
    when(healthCheck.checkJMS()).thenReturn(new HealthStatus(2, true));
    when(healthCheck.checkSignatureQueue()).thenReturn(new HealthStatus(signatureQueueMeasure, true));
    when(healthCheck.checkIntygstjanst()).thenReturn(new HealthStatus(4, true));
    when(healthCheck.checkPrivatlakarportal()).thenReturn(new HealthStatus(5, true));
    when(healthCheck.checkUptime()).thenReturn(new HealthStatus(6, true));
    when(healthCheck.checkNbrOfUsers()).thenReturn(new HealthStatus(nbrUsersMeasure, true));
    PingForConfigurationResponseType res = responder.pingForConfiguration("logicalAddress", new PingForConfigurationType());
    assertNotNull(res);
    assertNotNull(res.getPingDateTime());
    assertEquals(PROJECT_VERSION, res.getVersion());
    assertEquals(BUILD_NUMBER, res.getConfiguration().stream().filter(c -> "buildNumber".equals(c.getName())).findAny().get().getValue());
    assertEquals(BUILD_TIME, res.getConfiguration().stream().filter(c -> "buildTime".equals(c.getName())).findAny().get().getValue());
    assertNotNull(res.getConfiguration().stream().filter(c -> "systemUptime".equals(c.getName())).findAny().get().getValue());
    assertEquals("ok", res.getConfiguration().stream().filter(c -> "dbStatus".equals(c.getName())).findAny().get().getValue());
    assertEquals("ok", res.getConfiguration().stream().filter(c -> "jmsStatus".equals(c.getName())).findAny().get().getValue());
    assertEquals("ok", res.getConfiguration().stream().filter(c -> "intygstjanst".equals(c.getName())).findAny().get().getValue());
    assertEquals("ok", res.getConfiguration().stream().filter(c -> "privatlakarportal".equals(c.getName())).findAny().get().getValue());
    assertEquals("" + signatureQueueMeasure, res.getConfiguration().stream().filter(c -> "signatureQueueSize".equals(c.getName())).findAny().get().getValue());
    assertEquals("" + nbrUsersMeasure, res.getConfiguration().stream().filter(c -> "nbrOfUsers".equals(c.getName())).findAny().get().getValue());
    verify(healthCheck).checkDB();
    verify(healthCheck).checkJMS();
    verify(healthCheck).checkSignatureQueue();
    verify(healthCheck).checkIntygstjanst();
    verify(healthCheck).checkPrivatlakarportal();
    verify(healthCheck).checkUptime();
    verify(healthCheck).checkNbrOfUsers();
}
Also used : PingForConfigurationType(se.riv.itintegration.monitoring.v1.PingForConfigurationType) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) PingForConfigurationResponseType(se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType) Test(org.junit.Test)

Example 3 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class HealthCheckApiController method checkIntygstjanst.

@GET
@Path("/intygstjanst")
@Produces(MediaType.APPLICATION_XML)
public Response checkIntygstjanst() {
    HealthStatus status = healthCheck.checkIntygstjanst();
    String xmlResponse = buildXMLResponse(status);
    return Response.ok(xmlResponse).build();
}
Also used : HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class HealthCheckApiController method checkJMS.

@GET
@Path("/jms")
@Produces(MediaType.APPLICATION_XML)
public Response checkJMS() {
    HealthStatus status = healthCheck.checkJMS();
    String xmlResponse = buildXMLResponse(status);
    return Response.ok(xmlResponse).build();
}
Also used : HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with HealthStatus

use of se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus in project webcert by sklintyg.

the class HealthCheckApiController method checkPrivatlakarportal.

@GET
@Path("/privatlakarportal")
@Produces(MediaType.APPLICATION_XML)
public Response checkPrivatlakarportal() {
    HealthStatus status = healthCheck.checkPrivatlakarportal();
    String xmlResponse = buildXMLResponse(status);
    return Response.ok(xmlResponse).build();
}
Also used : HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

HealthStatus (se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus)30 Test (org.junit.Test)18 PingForConfigurationType (se.riv.itintegration.monitoring.v1.PingForConfigurationType)8 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 PingForConfigurationResponseType (se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType)5 Stopwatch (com.google.common.base.Stopwatch)4 JMSException (javax.jms.JMSException)2 Query (javax.persistence.Query)2 WebServiceException (javax.xml.ws.WebServiceException)2 BrowserCallback (org.springframework.jms.core.BrowserCallback)2 Time (java.sql.Time)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Connection (javax.jms.Connection)1 Transactional (org.springframework.transaction.annotation.Transactional)1