Search in sources :

Example 1 with ERROR

use of ch.qos.logback.classic.Level.ERROR in project neonbee by SAP.

the class LoggerManagerVerticleTest method testUpdateData.

@Test
@Timeout(value = 2, timeUnit = TimeUnit.SECONDS)
void testUpdateData(VertxTestContext testContext) {
    List<LoggerConfiguration> configList = List.of(new LoggerConfiguration("io.neonbee.internal", ERROR), new LoggerConfiguration("io.vertx.core.file", ERROR));
    DataRequest updateReq = new DataRequest(LoggerManagerVerticle.QUALIFIED_NAME, new DataQuery().setAction(DataAction.UPDATE).setBody(new JsonArray(configList.stream().map(LoggerConfiguration::toJson).collect(Collectors.toList())).toBuffer()));
    requestData(updateReq).compose(updateResponse -> {
        return this.<JsonArray>requestData(new DataRequest(LoggerManagerVerticle.QUALIFIED_NAME, new DataQuery()));
    }).onComplete(testContext.<JsonArray>succeeding(resp -> {
        assertThat(resp).isNotEmpty();
        Optional<String> level = resp.stream().map(JsonObject.class::cast).map(LoggerConfiguration::fromJson).filter(config -> "io.neonbee.internal".equals(config.getName())).findFirst().map(LoggerConfiguration::getConfiguredLevel).map(theLevel -> theLevel.levelStr);
        assertThat(level.isPresent()).isTrue();
        assertThat(level.get()).isEqualTo("ERROR");
        level = resp.stream().map(JsonObject.class::cast).map(LoggerConfiguration::fromJson).filter(config -> "io.vertx.core.file".equals(config.getName())).findFirst().map(LoggerConfiguration::getConfiguredLevel).map(theLevel -> theLevel.levelStr);
        assertThat(level.isPresent()).isTrue();
        assertThat(level.get()).isEqualTo("ERROR");
        testContext.completeNow();
    }));
}
Also used : JsonArray(io.vertx.core.json.JsonArray) VertxTestContext(io.vertx.junit5.VertxTestContext) BeforeEach(org.junit.jupiter.api.BeforeEach) DataAction(io.neonbee.data.DataAction) NO_WEB(io.neonbee.NeonBeeProfile.NO_WEB) Truth.assertThat(com.google.common.truth.Truth.assertThat) Collectors(java.util.stream.Collectors) Future(io.vertx.core.Future) TestInfo(org.junit.jupiter.api.TestInfo) Timeout(io.vertx.junit5.Timeout) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) JsonArray(io.vertx.core.json.JsonArray) List(java.util.List) DataRequest(io.neonbee.data.DataRequest) ERROR(ch.qos.logback.classic.Level.ERROR) DataQuery(io.neonbee.data.DataQuery) DataVerticleTestBase(io.neonbee.test.base.DataVerticleTestBase) Optional(java.util.Optional) JsonObject(io.vertx.core.json.JsonObject) NeonBeeOptions(io.neonbee.NeonBeeOptions) Optional(java.util.Optional) JsonObject(io.vertx.core.json.JsonObject) DataRequest(io.neonbee.data.DataRequest) DataQuery(io.neonbee.data.DataQuery) Test(org.junit.jupiter.api.Test) Timeout(io.vertx.junit5.Timeout)

Example 2 with ERROR

use of ch.qos.logback.classic.Level.ERROR in project styx by ExpediaGroup.

the class FsmEventProcessorTest method setUp.

@BeforeEach
public void setUp() {
    stateMachine = new StateMachine.Builder<String>().initialState("start").transition("start", TestEventOk.class, event -> "end").transition("start", TestEventError.class, event -> {
        throw new RuntimeException("Test exception message");
    }).onInappropriateEvent((x, y) -> "error").build();
    errorHandler = mock(BiConsumer.class);
    logger = new LoggingTestSupport(FsmEventProcessor.class);
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) BeforeEach(org.junit.jupiter.api.BeforeEach) LoggingTestSupport(com.hotels.styx.support.matchers.LoggingTestSupport) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) Matchers.any(org.mockito.Matchers.any) LoggingEventMatcher.loggingEvent(com.hotels.styx.support.matchers.LoggingEventMatcher.loggingEvent) AfterEach(org.junit.jupiter.api.AfterEach) ERROR(ch.qos.logback.classic.Level.ERROR) Matchers.eq(org.mockito.Matchers.eq) BiConsumer(java.util.function.BiConsumer) Matchers.is(org.hamcrest.Matchers.is) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Mockito.mock(org.mockito.Mockito.mock) LoggingTestSupport(com.hotels.styx.support.matchers.LoggingTestSupport) BiConsumer(java.util.function.BiConsumer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ERROR (ch.qos.logback.classic.Level.ERROR)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 LoggingEventMatcher.loggingEvent (com.hotels.styx.support.matchers.LoggingEventMatcher.loggingEvent)1 LoggingTestSupport (com.hotels.styx.support.matchers.LoggingTestSupport)1 NeonBeeOptions (io.neonbee.NeonBeeOptions)1 NO_WEB (io.neonbee.NeonBeeProfile.NO_WEB)1 DataAction (io.neonbee.data.DataAction)1 DataQuery (io.neonbee.data.DataQuery)1 DataRequest (io.neonbee.data.DataRequest)1 DataVerticleTestBase (io.neonbee.test.base.DataVerticleTestBase)1 Future (io.vertx.core.Future)1 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1 Timeout (io.vertx.junit5.Timeout)1 VertxTestContext (io.vertx.junit5.VertxTestContext)1 List (java.util.List)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1