Package com.seyren.core.domain

Examples of com.seyren.core.domain.Check


        when(mockSeyrenConfig.getTwilioAccountSid()).thenReturn(ACCOUNT_SID);
        when(mockSeyrenConfig.getTwilioAuthToken()).thenReturn("5678");
        when(mockSeyrenConfig.getTwilioPhoneNumber()).thenReturn("+11234567890");
        when(mockSeyrenConfig.getBaseUrl()).thenReturn(seyrenUrl);
       
        Check check = new Check()
                .withEnabled(true)
                .withName("check-name")
                .withState(AlertType.ERROR);
       
        Subscription subscription = new Subscription()
View Full Code Here


        String seyrenUrl = clientDriver.getBaseUrl() + "/seyren";
       
        when(mockSeyrenConfig.getGraphiteUrl()).thenReturn(clientDriver.getBaseUrl() + "/graphite");
        when(mockSeyrenConfig.getBaseUrl()).thenReturn(seyrenUrl);
       
        Check check = new Check()
                .withEnabled(true)
                .withName("check-name")
                .withTarget("statsd.metric.name")
                .withState(AlertType.ERROR)
                .withWarn(BigDecimal.ONE)
                .withError(BigDecimal.TEN);
       
        Subscription subscription = new Subscription()
                .withType(SubscriptionType.HTTP)
                .withTarget(clientDriver.getBaseUrl() + "/myendpoint/thatdoesstuff");
       
        Alert alert = new Alert()
                .withTarget("the.target.name")
                .withValue(BigDecimal.valueOf(12))
                .withWarn(BigDecimal.valueOf(5))
                .withError(BigDecimal.valueOf(10))
                .withFromType(AlertType.WARN)
                .withToType(AlertType.ERROR);
       
        List<Alert> alerts = Arrays.asList(alert);
       
        BodyCapture<JsonNode> bodyCapture = new JsonBodyCapture();
       
        clientDriver.addExpectation(
                onRequestTo("/myendpoint/thatdoesstuff")
                        .withMethod(Method.POST)
                        .capturingBodyIn(bodyCapture),
                giveResponse("success", "text/plain"));
       
        service.sendNotification(check, subscription, alerts);
       
        JsonNode node = bodyCapture.getContent();
       
       
        assertThat(node, hasJsonPath("$.seyrenUrl", is(seyrenUrl)));
        assertThat(node, hasJsonPath("$.check.name", is("check-name")));
        assertThat(node, hasJsonPath("$.check.state", is("ERROR")));
        assertThat(node, hasJsonPath("$.alerts", hasSize(1)));
        assertThat(node, hasJsonPath("$.alerts[0].target", is("the.target.name")));
        assertThat(node, hasJsonPath("$.alerts[0].value", is(12)));
        assertThat(node, hasJsonPath("$.alerts[0].warn", is(5)));
        assertThat(node, hasJsonPath("$.alerts[0].error", is(10)));
        assertThat(node, hasJsonPath("$.alerts[0].fromType", is("WARN")));
        assertThat(node, hasJsonPath("$.alerts[0].toType", is("ERROR")));
        assertThat(node, hasJsonPath("$.preview", Matchers.startsWith("<br />")));
        assertThat(node, hasJsonPath("$.preview", containsString(check.getTarget())));
       
        verify(mockSeyrenConfig).getGraphiteUrl();
        verify(mockSeyrenConfig).getBaseUrl();
       
    }
View Full Code Here

TOP

Related Classes of com.seyren.core.domain.Check

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.