-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
3ab95bb
commit bcc2b76
Showing
7 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/main/java/com/vzurauskas/nereides/javax/EmptyJson.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,14 @@ | ||
package com.vzurauskas.nereides.javax; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* Empty {@link Json}. It is equivalent to {@code new Json.Of("{}")}. | ||
*/ | ||
public final class EmptyJson implements Json { | ||
@Override | ||
public InputStream bytes() { | ||
return new ByteArrayInputStream("{}".getBytes()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/vzurauskas/nereides/javax/MissingJson.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,18 @@ | ||
package com.vzurauskas.nereides.javax; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* {@link Json}, which is missing. It is equivalent to | ||
* {@code new Json.Of(new byte[0])}. | ||
*/ | ||
public final class MissingJson implements Json { | ||
|
||
private static final byte[] MISSING = new byte[0]; | ||
|
||
@Override | ||
public InputStream bytes() { | ||
return new ByteArrayInputStream(MISSING); | ||
} | ||
} |
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: 13 additions & 0 deletions
13
src/test/java/com/vzurauskas/nereides/javax/EmptyJsonTest.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,13 @@ | ||
package com.vzurauskas.nereides.javax; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
final class EmptyJsonTest { | ||
@Test | ||
void creates() { | ||
new EqualityAssertion( | ||
new Json.Of("{}"), | ||
new EmptyJson() | ||
).affirm(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/java/com/vzurauskas/nereides/javax/EqualityAssertion.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,20 @@ | ||
package com.vzurauskas.nereides.javax; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public final class EqualityAssertion { | ||
private final Json first; | ||
private final Json second; | ||
|
||
public EqualityAssertion(Json first, Json second) { | ||
this.first = first; | ||
this.second = second; | ||
} | ||
|
||
public void affirm() { | ||
assertEquals( | ||
new SmartJson(first).pretty(), | ||
new SmartJson(second).pretty() | ||
); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/java/com/vzurauskas/nereides/javax/MissingJsonTest.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,15 @@ | ||
package com.vzurauskas.nereides.javax; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import java.io.IOException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
final class MissingJsonTest { | ||
@Test | ||
void creates() throws IOException { | ||
assertEquals( | ||
0, | ||
new MissingJson().bytes().available() | ||
); | ||
} | ||
} |
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