-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
170 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 5 additions & 8 deletions
13
heylogs-api/src/test/java/internal/heylogs/ExtendedRulesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
heylogs-api/src/test/java/tests/heylogs/spi/FormatAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package tests.heylogs.spi; | ||
|
||
import lombok.NonNull; | ||
import nbbrd.heylogs.spi.Format; | ||
|
||
import static java.util.Collections.emptyList; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatNullPointerException; | ||
|
||
public final class FormatAssert { | ||
|
||
private FormatAssert() { | ||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated"); | ||
} | ||
|
||
@SuppressWarnings("DataFlowIssue") | ||
public static void assertFormatCompliance(@NonNull Format x) { | ||
assertThat(x.getFormatId()) | ||
.matches(nbbrd.heylogs.spi.FormatLoader.ID_PATTERN); | ||
|
||
assertThat(x.getFormatName()) | ||
.isNotEmpty() | ||
.isNotNull(); | ||
|
||
assertThat(x.getFormatCategory()) | ||
.isNotEmpty() | ||
.isNotNull(); | ||
|
||
assertThat(x.getSupportedFormatTypes()) | ||
.isNotNull(); | ||
|
||
assertThatNullPointerException() | ||
.isThrownBy(() -> x.formatStatus(null, emptyList())); | ||
|
||
assertThatNullPointerException() | ||
.isThrownBy(() -> x.formatStatus(new StringBuilder(), null)); | ||
|
||
assertThatNullPointerException() | ||
.isThrownBy(() -> x.formatResources(null, emptyList())); | ||
|
||
assertThatNullPointerException() | ||
.isThrownBy(() -> x.formatResources(new StringBuilder(), null)); | ||
|
||
assertThatNullPointerException() | ||
.isThrownBy(() -> x.formatProblems(null, emptyList())); | ||
|
||
assertThatNullPointerException() | ||
.isThrownBy(() -> x.formatProblems(new StringBuilder(), null)); | ||
|
||
assertThat(x.getClass()) | ||
.isFinal(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.github.nbbrd.heylogs</groupId> | ||
<artifactId>heylogs-parent</artifactId> | ||
<version>0.8.2-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>heylogs-ext-json</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<!-- compile only --> | ||
<dependency> | ||
<groupId>org.checkerframework</groupId> | ||
<artifactId>checker-qual</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.nbbrd.java-design-util</groupId> | ||
<artifactId>java-design-processor</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.nbbrd.java-service-util</groupId> | ||
<artifactId>java-service-processor</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- compile and runtime --> | ||
<dependency> | ||
<artifactId>heylogs-api</artifactId> | ||
<groupId>${project.groupId}</groupId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
<version>2.11.0</version> | ||
</dependency> | ||
|
||
<!-- test only --> | ||
<dependency> | ||
<artifactId>heylogs-api</artifactId> | ||
<groupId>${project.groupId}</groupId> | ||
<version>${project.version}</version> | ||
<classifier>tests</classifier> | ||
<type>test-jar</type> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
2 changes: 1 addition & 1 deletion
2
...ain/java/internal/heylogs/JsonFormat.java → ...va/nbbrd/heylogs/ext/json/JsonFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package internal.heylogs; | ||
package nbbrd.heylogs.ext.json; | ||
|
||
import com.google.gson.*; | ||
import lombok.NonNull; | ||
|
27 changes: 13 additions & 14 deletions
27
...java/internal/heylogs/JsonFormatTest.java → ...bbrd/heylogs/ext/json/JsonFormatTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,59 @@ | ||
package internal.heylogs; | ||
package nbbrd.heylogs.ext.json; | ||
|
||
import nbbrd.heylogs.spi.Format; | ||
import nbbrd.heylogs.spi.FormatLoader; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static tests.heylogs.api.Sample.*; | ||
import static java.util.Arrays.asList; | ||
import static java.util.Collections.emptyList; | ||
import static java.util.Collections.singletonList; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static tests.heylogs.api.Sample.*; | ||
import static tests.heylogs.spi.FormatAssert.assertFormatCompliance; | ||
|
||
class JsonFormatTest { | ||
|
||
@Test | ||
public void testIdPattern() { | ||
assertThat(new JsonFormat().getFormatId()) | ||
.matches(FormatLoader.ID_PATTERN); | ||
public void testCompliance() { | ||
assertFormatCompliance(new JsonFormat()); | ||
} | ||
|
||
@Test | ||
public void testFormatProblems() { | ||
Format x = new JsonFormat(); | ||
|
||
assertThat(writing(appendable -> x.formatProblems(appendable, singletonList(CHECK1)))) | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "check1.json")); | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "/check1.json")); | ||
|
||
assertThat(writing(appendable -> x.formatProblems(appendable, singletonList(CHECK2)))) | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "check2.json")); | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "/check2.json")); | ||
|
||
assertThat(writing(appendable -> x.formatProblems(appendable, singletonList(CHECK3)))) | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "check3.json")); | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "/check3.json")); | ||
} | ||
|
||
@Test | ||
public void testFormatStatus() { | ||
Format x = new JsonFormat(); | ||
|
||
assertThat(writing(appendable -> x.formatStatus(appendable, singletonList(SCAN1)))) | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "scan1.json")); | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "/scan1.json")); | ||
|
||
assertThat(writing(appendable -> x.formatStatus(appendable, singletonList(SCAN2)))) | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "scan2.json")); | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "/scan2.json")); | ||
} | ||
|
||
@Test | ||
public void testFormatResource() { | ||
Format x = new JsonFormat(); | ||
|
||
assertThat(writing(appendable -> x.formatResources(appendable, emptyList()))) | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "resource1.json")); | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "/resource1.json")); | ||
|
||
assertThat(writing(appendable -> x.formatResources(appendable, singletonList(RESOURCE1)))) | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "resource2.json")); | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "/resource2.json")); | ||
|
||
assertThat(writing(appendable -> x.formatResources(appendable, asList(RESOURCE1, RESOURCE2)))) | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "resource3.json")); | ||
.isEqualToNormalizingNewlines(contentOf(JsonFormatTest.class, "/resource3.json")); | ||
} | ||
|
||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters