diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index fe7cb54..7ff50a2 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -7,19 +7,21 @@ on: # The branches below must be a subset of the branches above branches: [ "**" ] +permissions: read-all + jobs: analyze: name: Analyze runs-on: ubuntu-latest timeout-minutes: 15 permissions: - actions: read - contents: read security-events: write strategy: fail-fast: false matrix: - language: [ 'java' ] + include: + - language: java-kotlin + build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too. steps: - name: Checkout repository uses: actions/checkout@v4 @@ -32,8 +34,7 @@ jobs: uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - - name: Autobuild - uses: github/codeql-action/autobuild@v3 + build-mode: ${{ matrix.build-mode }} - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 with: diff --git a/.github/workflows/sonatype.yml b/.github/workflows/sonatype.yml index 007ae3e..a8ac6e9 100644 --- a/.github/workflows/sonatype.yml +++ b/.github/workflows/sonatype.yml @@ -4,14 +4,13 @@ on: release: types: [ created ] +permissions: read-all + jobs: publish: name: Publish to Maven Central runs-on: ubuntu-latest timeout-minutes: 15 - permissions: - actions: read - contents: read steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/core/src/test/java/io/github/vitalijr2/aws/lambda/slf4j/AWSLambdaLoggerFactoryTest.java b/core/src/test/java/io/github/vitalijr2/aws/lambda/slf4j/AWSLambdaLoggerFactoryTest.java index 5ca02b1..c3c26c6 100644 --- a/core/src/test/java/io/github/vitalijr2/aws/lambda/slf4j/AWSLambdaLoggerFactoryTest.java +++ b/core/src/test/java/io/github/vitalijr2/aws/lambda/slf4j/AWSLambdaLoggerFactoryTest.java @@ -3,25 +3,34 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.verify; import org.example.ServiceProvider; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.slf4j.event.Level; +@ExtendWith(MockitoExtension.class) @Tag("slow") class AWSLambdaLoggerFactoryTest { + @Mock + private AWSLambdaLoggerConfiguration configuration; + @DisplayName("Custom output service provider") @Test void customOutputServiceProvider() { // when - var serviceProvider = (ServiceProvider) assertDoesNotThrow( + var loggerOutput = assertDoesNotThrow( () -> AWSLambdaLoggerFactory.getOutputServiceProvider(ServiceProvider.class)); - var message = serviceProvider.hello(); + loggerOutput.log(configuration, null, Level.TRACE, "test message", null); // then - assertEquals("hello world", message); + verify(configuration).isLevelEnabled(Level.TRACE); } @DisplayName("No output service providers") diff --git a/core/src/test/java/org/example/ServiceProvider.java b/core/src/test/java/org/example/ServiceProvider.java index 9ce7c7c..8d4cca1 100644 --- a/core/src/test/java/org/example/ServiceProvider.java +++ b/core/src/test/java/org/example/ServiceProvider.java @@ -1,9 +1,11 @@ package org.example; +import io.github.vitalijr2.aws.lambda.slf4j.AWSLambdaLoggerConfiguration; import io.github.vitalijr2.aws.lambda.slf4j.AWSLambdaLoggerOutput; +import org.slf4j.event.Level; public interface ServiceProvider extends AWSLambdaLoggerOutput { - String hello(); + void hello(AWSLambdaLoggerConfiguration configuration, Level level); } diff --git a/core/src/test/java/org/example/TestServiceProvider.java b/core/src/test/java/org/example/TestServiceProvider.java index a8c454b..58ec9b6 100644 --- a/core/src/test/java/org/example/TestServiceProvider.java +++ b/core/src/test/java/org/example/TestServiceProvider.java @@ -9,14 +9,14 @@ public class TestServiceProvider implements ServiceProvider { @Override - public String hello() { - return "hello world"; + public void hello(AWSLambdaLoggerConfiguration configuration, Level level) { + configuration.isLevelEnabled(level); } @Override public void log(@NotNull AWSLambdaLoggerConfiguration configuration, @Nullable Marker marker, @NotNull Level level, @NotNull String message, @Nullable Throwable throwable) { - hello(); + hello(configuration, level); } } diff --git a/pom.xml b/pom.xml index 70510e0..99b04d3 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,7 @@ org.apache.maven.plugins - 3.3.1 + 3.5.1 maven-jar-plugin @@ -124,7 +124,7 @@ org.apache.maven.plugins - 3.3.1 + 3.5.1 jacoco-maven-plugin @@ -268,7 +268,7 @@ true org.sonatype.central - 0.5.0 + 0.6.0 @@ -315,7 +315,7 @@ annotations org.jetbrains provided - 24.1.0 + 26.0.1 aws-lambda-java-core @@ -325,7 +325,7 @@ aws-lambda-java-events com.amazonaws - 3.13.0 + 3.14.0 slf4j-api @@ -439,12 +439,12 @@ 11 - 3.8.0 - 5.10.3 - 5.12.0 + 3.10.1 + 5.11.3 + 5.14.2 UTF-8 2.0.16 - 2.1.6 + 2.1.7 scm:git:https://github.com/vitalijr2/aws-lambda-slf4j.git