Search in sources :

Example 11 with HealthStatus

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

the class HealthCheckServiceImplTest method testCheckSignatureQueueException.

@SuppressWarnings("unchecked")
@Test
public void testCheckSignatureQueueException() {
    when(jmsCertificateSenderTemplate.browse(any(BrowserCallback.class))).thenThrow(new RuntimeException(""));
    HealthStatus res = service.checkSignatureQueue();
    assertNotNull(res);
    assertFalse(res.isOk());
    assertEquals(-1, res.getMeasurement());
}
Also used : BrowserCallback(org.springframework.jms.core.BrowserCallback) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Test(org.junit.Test)

Example 12 with HealthStatus

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

the class HealthCheckServiceImplTest method testCheckJMS.

@Test
public void testCheckJMS() throws JMSException {
    when(connectionFactory.createConnection()).thenReturn(mock(Connection.class));
    HealthStatus res = service.checkJMS();
    assertNotNull(res);
    assertTrue(res.isOk());
    assertNotNull(res.getMeasurement());
}
Also used : Connection(javax.jms.Connection) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Test(org.junit.Test)

Example 13 with HealthStatus

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

the class HealthCheckServiceImplTest method testCheckIntygstjanstException.

@Test
public void testCheckIntygstjanstException() {
    when(intygstjanstPingForConfiguration.pingForConfiguration(eq(IT_LOGICAL_ADDRESS), any(PingForConfigurationType.class))).thenThrow(new WebServiceException());
    HealthStatus res = service.checkIntygstjanst();
    assertNotNull(res);
    assertFalse(res.isOk());
    assertNotNull(res.getMeasurement());
}
Also used : PingForConfigurationType(se.riv.itintegration.monitoring.v1.PingForConfigurationType) WebServiceException(javax.xml.ws.WebServiceException) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Test(org.junit.Test)

Example 14 with HealthStatus

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

the class HealthCheckServiceImplTest method testCheckIntygstjanstNullResponse.

@Test
public void testCheckIntygstjanstNullResponse() {
    when(intygstjanstPingForConfiguration.pingForConfiguration(eq(IT_LOGICAL_ADDRESS), any(PingForConfigurationType.class))).thenReturn(null);
    HealthStatus res = service.checkIntygstjanst();
    assertNotNull(res);
    assertFalse(res.isOk());
    assertNotNull(res.getMeasurement());
    verify(intygstjanstPingForConfiguration).pingForConfiguration(eq(IT_LOGICAL_ADDRESS), any(PingForConfigurationType.class));
}
Also used : PingForConfigurationType(se.riv.itintegration.monitoring.v1.PingForConfigurationType) HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Test(org.junit.Test)

Example 15 with HealthStatus

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

the class HealthCheckServiceImplTest method testCheckNbrOfUsers.

@Test
public void testCheckNbrOfUsers() {
    when(sessionRegistry.getAllPrincipals()).thenReturn(Arrays.asList("principal1", "principal2"));
    HealthStatus res = service.checkNbrOfUsers();
    assertNotNull(res);
    assertTrue(res.isOk());
    assertEquals(2, res.getMeasurement());
}
Also used : HealthStatus(se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus) Test(org.junit.Test)

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