Search in sources :

Example 1 with PingForConfigurationResponseType

use of se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType 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 PingForConfigurationResponseType

use of se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType 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 PingForConfigurationResponseType

use of se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType in project webcert by sklintyg.

the class HealthCheckServiceImplTest method testCheckIntygstjanst.

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

Example 4 with PingForConfigurationResponseType

use of se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType in project webcert by sklintyg.

the class HealthCheckServiceImpl method pingPrivatlakarportal.

private boolean pingPrivatlakarportal() {
    try {
        PingForConfigurationType parameters = new PingForConfigurationType();
        PingForConfigurationResponseType pingResponse = privatlakarportalPingForConfiguration.pingForConfiguration(ppLogicalAddress, parameters);
        return pingResponse != null;
    } catch (Exception e) {
        LOG.error("pingPrivatlakarportal failed with exception: " + e.getMessage());
        return false;
    }
}
Also used : PingForConfigurationType(se.riv.itintegration.monitoring.v1.PingForConfigurationType) PingForConfigurationResponseType(se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType) JMSException(javax.jms.JMSException)

Example 5 with PingForConfigurationResponseType

use of se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType in project webcert by sklintyg.

the class PingForConfigurationResponderImpl method addConfiguration.

private void addConfiguration(PingForConfigurationResponseType response, String name, String value) {
    ConfigurationType conf = new ConfigurationType();
    conf.setName(name);
    conf.setValue(value);
    response.getConfiguration().add(conf);
}
Also used : ConfigurationType(se.riv.itintegration.monitoring.v1.ConfigurationType) PingForConfigurationType(se.riv.itintegration.monitoring.v1.PingForConfigurationType)

Aggregations

PingForConfigurationResponseType (se.riv.itintegration.monitoring.v1.PingForConfigurationResponseType)7 PingForConfigurationType (se.riv.itintegration.monitoring.v1.PingForConfigurationType)7 HealthStatus (se.inera.intyg.webcert.web.service.monitoring.dto.HealthStatus)5 Test (org.junit.Test)4 JMSException (javax.jms.JMSException)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 ConfigurationType (se.riv.itintegration.monitoring.v1.ConfigurationType)1