-
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.
New !URI syntax for remote data request ($LATEST$) on template variables
- Loading branch information
1 parent
9ff52e6
commit 0e09faf
Showing
9 changed files
with
148 additions
and
16 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
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
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
45 changes: 45 additions & 0 deletions
45
src/main/java/com/asteroid/duck/velociwraptor/util/FakeJsonString.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,45 @@ | ||
package com.asteroid.duck.velociwraptor.util; | ||
|
||
import javax.json.JsonString; | ||
import java.util.Objects; | ||
|
||
public class FakeJsonString implements JsonString { | ||
private final String string; | ||
|
||
public FakeJsonString(String string) { | ||
this.string = string; | ||
} | ||
|
||
@Override | ||
public String getString() { | ||
return string; | ||
} | ||
|
||
@Override | ||
public CharSequence getChars() { | ||
return string; | ||
} | ||
|
||
@Override | ||
public ValueType getValueType() { | ||
return ValueType.STRING; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || !(o instanceof JsonString)) return false; | ||
JsonString that = (JsonString) o; | ||
return Objects.equals(string, that.getString()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(string); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return string; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/com/asteroid/duck/velociwraptor/model/JsonTemplateDataTest.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,38 @@ | ||
package com.asteroid.duck.velociwraptor.model; | ||
|
||
import com.asteroid.duck.velociwraptor.user.UserInteractive; | ||
import com.asteroid.duck.velociwraptor.util.FakeJsonString; | ||
import org.junit.Test; | ||
|
||
import javax.json.Json; | ||
import javax.json.JsonObject; | ||
import javax.json.JsonReader; | ||
|
||
import java.io.StringReader; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class JsonTemplateDataTest { | ||
|
||
private static final String TEST_FILE = "test.json"; | ||
|
||
public static final JsonObject parseString(String json) | ||
{ | ||
JsonReader reader = Json.createReader(new StringReader(json)); | ||
return reader.readObject(); | ||
} | ||
|
||
public static final JsonObject parseResource(String resource) | ||
{ | ||
JsonReader reader = Json.createReader(JsonTemplateDataTest.class.getResourceAsStream(resource)); | ||
return reader.readObject(); | ||
} | ||
|
||
@Test | ||
public void get() { | ||
JsonObject test = parseResource(TEST_FILE); | ||
JsonTemplateData subject = new JsonTemplateData(test, UserInteractive.nullInteractive()); | ||
assertEquals(new FakeJsonString("Chris Senior"), subject.get("Author")); | ||
assertEquals(new FakeJsonString("6.0.1"), subject.get("GradleVersion")); | ||
} | ||
} |
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