Search in sources :

Example 16 with Jsonb

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"));
}
Also used : Jsonb(jakarta.json.bind.Jsonb) Test(org.junit.Test)

Example 17 with Jsonb

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());
}
Also used : Jsonb(jakarta.json.bind.Jsonb) Test(org.junit.Test)

Example 18 with Jsonb

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);
}
Also used : Jsonb(jakarta.json.bind.Jsonb) Test(org.junit.Test)

Example 19 with Jsonb

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));
}
Also used : Jsonb(jakarta.json.bind.Jsonb) Test(org.junit.Test)

Example 20 with Jsonb

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"))));
}
Also used : Jsonb(jakarta.json.bind.Jsonb) Test(org.junit.Test)

Aggregations

Jsonb (jakarta.json.bind.Jsonb)50 Test (org.junit.Test)28 JsonbConfig (jakarta.json.bind.JsonbConfig)12 Test (org.junit.jupiter.api.Test)6 InputStream (java.io.InputStream)4 Files.newInputStream (java.nio.file.Files.newInputStream)3 Path (java.nio.file.Path)3 ZpmSecurity (io.aklivity.zilla.manager.internal.settings.ZpmSecurity)2 Annot8ComponentDescriptor (io.annot8.api.components.Annot8ComponentDescriptor)2 Descriptor (io.annot8.common.serialization.TestNested.Descriptor)2 OutputStream (java.io.OutputStream)2 Files.newOutputStream (java.nio.file.Files.newOutputStream)2 ZpmCredentials (io.aklivity.zilla.manager.internal.settings.ZpmCredentials)1 ZpmSettings (io.aklivity.zilla.manager.internal.settings.ZpmSettings)1 Engine (io.aklivity.zilla.runtime.engine.Engine)1 EngineConfiguration (io.aklivity.zilla.runtime.engine.EngineConfiguration)1 BindingConfig (io.aklivity.zilla.runtime.engine.config.BindingConfig)1 NamespaceConfig (io.aklivity.zilla.runtime.engine.config.NamespaceConfig)1 RouteConfig (io.aklivity.zilla.runtime.engine.config.RouteConfig)1 VaultConfig (io.aklivity.zilla.runtime.engine.config.VaultConfig)1