Example usage for java.lang Throwable getClass

List of usage examples for java.lang Throwable getClass

Introduction

In this page you can find the example usage for java.lang Throwable getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.alliander.osgp.acceptancetests.deviceinstallation.StopDeviceTestSteps.java

@DomainStep("the stop device test response request should return a stop device test response with result (.*) and description (.*)")
public boolean thenTheStopDeviceTestResponseRequestShouldReturnAGetFirmwareVersionResponse(final String result,
        final String description) {
    LOGGER.info(/*w w w .  j a va 2  s .c  om*/
            "THEN: \"the stop device test response request should return a stop device test response with result {} and description {}",
            result, description);

    try {
        if ("NOT_OK".equals(result)) {
            Assert.assertNull("Set Schedule Response should be null", this.response);
            Assert.assertNotNull("Throwable should not be null", this.throwable);
            Assert.assertTrue("Throwable should contain a validation exception",
                    this.throwable.getCause() instanceof ValidationException);
        } else {

            Assert.assertNotNull("Response should not be null", this.response);

            final String expected = result.equals("NULL") ? null : result;
            final String actual = this.response.getResult().toString();

            Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected,
                    (actual == null && expected == null) || actual.equals(expected));
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetRebootSteps.java

@DomainStep("a set reboot oslp message is sent to device (.*) should be (.*)")
public boolean thenASetRebootOslpMessageShouldBeSent(final String device, final Boolean isMessageSent) {
    LOGGER.info("THEN: \"a set reboot oslp message is sent to device [{}] should be [{}]\".", device,
            isMessageSent);/*from ww  w.  j a v a2s . c  o m*/

    final int count = isMessageSent ? 1 : 0;

    try {
        final ArgumentCaptor<OslpEnvelope> argument = ArgumentCaptor.forClass(OslpEnvelope.class);
        verify(this.channelMock, timeout(10000).times(count)).write(argument.capture());

        if (isMessageSent) {
            this.oslpResponse = argument.getValue();

            Assert.assertTrue("Message should contain set reboot request.",
                    this.oslpResponse.getPayloadMessage().hasSetRebootRequest());

        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.firmwaremanagement.GetFirmwareVersionSteps.java

@DomainStep("a get firmware version oslp message is sent to device (.*) should be (.*)")
public boolean thenAGetFirmwareOslpMessageShouldBeSent(final String device, final Boolean isMessageSent) {
    LOGGER.info("THEN: a get firmware version oslp message is sent to device should be {}.", isMessageSent);

    final int count = isMessageSent ? 1 : 0;

    try {/*from   ww  w.j a  v a2s .  co  m*/
        final ArgumentCaptor<OslpEnvelope> argument = ArgumentCaptor.forClass(OslpEnvelope.class);
        verify(this.channelMock, timeout(10000).times(count)).write(argument.capture());

        if (isMessageSent) {
            this.oslpRequest = argument.getValue();

            Assert.assertTrue("Message should contain get firmware version request.",
                    this.oslpRequest.getPayloadMessage().hasGetFirmwareVersionRequest());
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.firmwaremanagement.GetFirmwareVersionSteps.java

@DomainStep("an ovl get firmware version message with result (.*) and firmwareversion (.*) should be sent to the ovl out queue")
public boolean thenAnOvlGetFirmwareVersionMessage(final String result, final String firmwareversion) {
    LOGGER.info(/*from  w ww .j a v a2 s . c o m*/
            "THEN: an ovl get firmware version message with result {} and firmwareversion {} should be sent to the ovl out queue.",
            result, firmwareversion);

    try {
        final ArgumentCaptor<ResponseMessage> argument = ArgumentCaptor.forClass(ResponseMessage.class);
        verify(this.webServiceResponseMessageSenderMock, timeout(10000).times(1)).send(argument.capture());

        final String expected = result.equals("NULL") ? null : result;
        final String actual = argument.getValue().getResult().getValue();

        Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected,
                actual.equals(expected));

    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.deviceinstallation.StartDeviceTestSteps.java

@DomainStep("the start device test response request should return a start device test response with result (.*) and description (.*)")
public boolean thenTheStartDeviceTestResponseRequestShouldReturnAStartDeviceTestResponse(final String result,
        final String description) {
    LOGGER.info(// w  w  w .  j a  v  a2 s.co  m
            "THEN: \"the start device test response request should return a start device test response with result {} and description {}",
            result, description);

    try {
        if ("NOT_OK".equals(result)) {
            Assert.assertNull("Set Schedule Response should be null", this.response);
            Assert.assertNotNull("Throwable should not be null", this.throwable);
            Assert.assertTrue("Throwable should contain a validation exception",
                    this.throwable.getCause() instanceof ValidationException);
        } else {

            Assert.assertNotNull("Response should not be null", this.response);

            final String expected = result.equals("NULL") ? null : result;
            final String actual = this.response.getResult().toString();

            Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected,
                    (actual == null && expected == null) || actual.equals(expected));
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetRebootSteps.java

@DomainStep("the get set reboot response request should return a set reboot response with result (.*) and description (.*)")
public boolean thenTheGetSetRebootResultRequestShouldReturnAGetSetRebootResultResponseWithResult(
        final String result, final String description) {
    LOGGER.info(/*from  w  w  w .  j  ava  2 s. co  m*/
            "THEN: \"the get set reboot result request should return a get set reboot response with result {} and description {}",
            result, description);

    try {
        if ("NOT_OK".equals(result)) {
            Assert.assertNull("Set Schedule Response should be null", this.response);
            Assert.assertNotNull("Throwable should not be null", this.throwable);
            Assert.assertTrue("Throwable should contain a validation exception",
                    this.throwable.getCause() instanceof ValidationException);
        } else {

            Assert.assertNotNull("Response should not be null", this.response);

            final String expectedResult = result.equals("NULL") ? null : result;
            final String actualResult = this.response.getResult().toString();

            Assert.assertTrue("Invalid result, found: " + actualResult + " , expected: " + expectedResult,
                    (actualResult == null && expectedResult == null) || actualResult.equals(expectedResult));
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetTransitionSteps.java

@DomainStep("a set transition oslp message is sent to the device should be (.*)")
public boolean thenAnOslpMessageShouldBeSent(final Boolean isMessageSent) {
    LOGGER.info("THEN: a set transition oslp message is sent to the device should be {}.", isMessageSent);

    final int count = isMessageSent ? 1 : 0;

    try {//from  w ww . java2 s.c  o m
        final ArgumentCaptor<OslpEnvelope> argument = ArgumentCaptor.forClass(OslpEnvelope.class);
        verify(this.channelMock, timeout(10000).times(count)).write(argument.capture());

        if (isMessageSent) {
            this.oslpRequest = argument.getValue();

            Assert.assertTrue("Message should contain set transition request.",
                    this.oslpRequest.getPayloadMessage().hasSetTransitionRequest());
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.espertech.esper.core.StatementResultServiceImpl.java

private void dispatchInternal(UniformPair<EventBean[]> events) {
    if (statementResultNaturalStrategy != null) {
        statementResultNaturalStrategy.execute(events);
    }//from   ww  w . ja va2s  .  c  o  m

    EventBean[] newEventArr = events != null ? events.getFirst() : null;
    EventBean[] oldEventArr = events != null ? events.getSecond() : null;

    for (UpdateListener listener : statementListenerSet.listeners) {
        try {
            listener.update(newEventArr, oldEventArr);
        } catch (Throwable t) {
            String message = "Unexpected exception invoking listener update method on listener class '"
                    + listener.getClass().getSimpleName() + "' : " + t.getClass().getSimpleName() + " : "
                    + t.getMessage();
            log.error(message, t);
        }
    }
    if (!(statementListenerSet.stmtAwareListeners.isEmpty())) {
        for (StatementAwareUpdateListener listener : statementListenerSet.getStmtAwareListeners()) {
            try {
                listener.update(newEventArr, oldEventArr, epStatement, epServiceProvider);
            } catch (Throwable t) {
                String message = "Unexpected exception invoking listener update method on listener class '"
                        + listener.getClass().getSimpleName() + "' : " + t.getClass().getSimpleName() + " : "
                        + t.getMessage();
                log.error(message, t);
            }
        }
    }
    if ((AuditPath.isAuditEnabled) && (!statementOutputHooks.isEmpty())) {
        for (StatementResultListener listener : statementOutputHooks) {
            listener.update(newEventArr, oldEventArr, epStatement.getName(), epStatement, epServiceProvider);
        }
    }
}

From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetTransitionSteps.java

@DomainStep("a set transition oslp message is sent to device (.*) should be (.*)")
public boolean thenASetTransitionOslpMessageShouldBeSent(final String device, final Boolean isMessageSent) {
    LOGGER.info("THEN: \"a set transition oslp message is sent to device [{}] should be [{}]\".", device,
            isMessageSent);//from   w  w w.j  a  va  2 s .co  m

    final int count = isMessageSent ? 1 : 0;

    try {
        final ArgumentCaptor<OslpEnvelope> argument = ArgumentCaptor.forClass(OslpEnvelope.class);
        verify(this.channelMock, timeout(10000).times(count)).write(argument.capture());

        if (isMessageSent) {
            this.oslpRequest = argument.getValue();

            Assert.assertTrue("Message should contain set transition request.",
                    this.oslpRequest.getPayloadMessage().hasSetTransitionRequest());
        }
    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}

From source file:com.alliander.osgp.acceptancetests.adhocmanagement.SetTransitionSteps.java

@DomainStep("an ovl set transition result message with result (.*) and description (.*) should be sent to the ovl out queue")
public boolean thenAnOvlSetTransitionResultMessageShouldBeSentToTheOvlOutQueue(final String result,
        final String description) {
    LOGGER.info(//from www . j a v  a 2  s  .  c om
            "THEN: \"an ovl set transition result message with result [{}] and description [{}] should be sent to the ovl out queue\".",
            result, description);

    try {
        final ArgumentCaptor<ResponseMessage> argument = ArgumentCaptor.forClass(ResponseMessage.class);
        verify(this.webServiceResponseMessageSenderMock, timeout(10000).times(1)).send(argument.capture());

        final String expected = result.equals("NULL") ? null : result;
        final String actual = argument.getValue().getResult().getValue();

        Assert.assertTrue("Invalid result, found: " + actual + " , expected: " + expected,
                actual.equals(expected));

    } catch (final Throwable t) {
        LOGGER.error("Exception [{}]: {}", t.getClass().getSimpleName(), t.getMessage());
        return false;
    }
    return true;
}