use of jakarta.json.bind.Jsonb in project zilla by aklivity.
the class ZpmSecurityTest method shouldReadSecurity.
@Test
public void shouldReadSecurity() {
String text = "{" + "\"secret\":\"whisper\"" + "}";
Jsonb builder = JsonbBuilder.create();
ZpmSecurity security = builder.fromJson(text, ZpmSecurity.class);
assertThat(security, not(nullValue()));
assertThat(security.secret, equalTo("whisper"));
}
use of jakarta.json.bind.Jsonb in project zilla by aklivity.
the class ZpmSecurityTest method shouldReadEmptySecurity.
@Test
public void shouldReadEmptySecurity() {
String text = "{" + "}";
Jsonb builder = JsonbBuilder.create();
ZpmSecurity security = builder.fromJson(text, ZpmSecurity.class);
assertThat(security, not(nullValue()));
assertThat(security.secret, nullValue());
}
use of jakarta.json.bind.Jsonb in project zilla by aklivity.
the class ZpmSecurityTest method shouldWriteSecurity.
@Test
public void shouldWriteSecurity() {
String expected = "{" + "\"secret\":\"whisper\"" + "}";
ZpmSecurity security = new ZpmSecurity();
security.secret = "whisper";
Jsonb builder = JsonbBuilder.create();
String actual = builder.toJson(security);
assertEquals(expected, actual);
}
use of jakarta.json.bind.Jsonb in project zilla by aklivity.
the class ZpmSettingsTest method shouldReadEmptyCredentials.
@Test
public void shouldReadEmptyCredentials() {
String text = "{" + "\"credentials\":" + "[" + "]" + "}";
Jsonb builder = JsonbBuilder.create();
ZpmSettings settings = builder.fromJson(text, ZpmSettings.class);
assertThat(settings, not(nullValue()));
assertThat(settings.credentials, not(nullValue()));
assertThat(settings.credentials, emptyCollectionOf(ZpmCredentials.class));
}
use of jakarta.json.bind.Jsonb in project zilla by aklivity.
the class ZpmSettingsTest method shouldReadCredential.
@Test
public void shouldReadCredential() {
String text = "{" + "\"credentials\":" + "[" + "{" + "\"realm\": \"HTTP Realm\"," + "\"host\": \"repo1.maven.org\"," + "\"username\": \"user\"," + "\"password\": \"pass\"" + "}" + "]" + "}";
Jsonb builder = JsonbBuilder.create();
ZpmSettings settings = builder.fromJson(text, ZpmSettings.class);
assertThat(settings, not(nullValue()));
assertThat(settings.credentials, not(nullValue()));
assertThat(settings.credentials, equalTo(singletonList(new ZpmCredentials("HTTP Realm", "repo1.maven.org", "user", "pass"))));
}
Aggregations