Search in sources :

Example 1 with PropertyDef

use of io.aklivity.zilla.runtime.engine.Configuration.PropertyDef in project zilla by aklivity.

the class ConfigurationTest method shouldSupplyDefaultFloatProperty.

@Test
public void shouldSupplyDefaultFloatProperty() {
    ConfigurationDef configDef = new ConfigurationDef("scope");
    FloatPropertyDef propertyDef = configDef.property("float.property.name", (ToFloatFunction<Configuration>) c -> 0.1234f);
    Configuration config = new Configuration();
    assertEquals(0.1234f, propertyDef.getAsFloat(config), 0.0f);
}
Also used : PropertyDef(io.aklivity.zilla.runtime.engine.Configuration.PropertyDef) Properties(java.util.Properties) IntPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.IntPropertyDef) BooleanPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BooleanPropertyDef) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) Predicate(java.util.function.Predicate) FloatPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.FloatPropertyDef) ToIntFunction(java.util.function.ToIntFunction) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) LongPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.LongPropertyDef) ToCharFunction(io.aklivity.zilla.runtime.engine.Configuration.ToCharFunction) BytePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BytePropertyDef) CharPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.CharPropertyDef) ToDoubleFunction(java.util.function.ToDoubleFunction) ToShortFunction(io.aklivity.zilla.runtime.engine.Configuration.ToShortFunction) ShortPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.ShortPropertyDef) ToFloatFunction(io.aklivity.zilla.runtime.engine.Configuration.ToFloatFunction) DoublePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.DoublePropertyDef) ToByteFunction(io.aklivity.zilla.runtime.engine.Configuration.ToByteFunction) ToLongFunction(java.util.function.ToLongFunction) Assert.assertEquals(org.junit.Assert.assertEquals) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) FloatPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.FloatPropertyDef) Test(org.junit.Test)

Example 2 with PropertyDef

use of io.aklivity.zilla.runtime.engine.Configuration.PropertyDef in project zilla by aklivity.

the class ConfigurationTest method shouldSupplyDefaultIntegerProperty.

@Test
public void shouldSupplyDefaultIntegerProperty() {
    ConfigurationDef configDef = new ConfigurationDef("scope");
    IntPropertyDef propertyDef = configDef.property("integer.property.name", (ToIntFunction<Configuration>) c -> 1234);
    Configuration config = new Configuration();
    assertEquals(1234, propertyDef.getAsInt(config));
}
Also used : PropertyDef(io.aklivity.zilla.runtime.engine.Configuration.PropertyDef) Properties(java.util.Properties) IntPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.IntPropertyDef) BooleanPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BooleanPropertyDef) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) Predicate(java.util.function.Predicate) FloatPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.FloatPropertyDef) ToIntFunction(java.util.function.ToIntFunction) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) LongPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.LongPropertyDef) ToCharFunction(io.aklivity.zilla.runtime.engine.Configuration.ToCharFunction) BytePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BytePropertyDef) CharPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.CharPropertyDef) ToDoubleFunction(java.util.function.ToDoubleFunction) ToShortFunction(io.aklivity.zilla.runtime.engine.Configuration.ToShortFunction) ShortPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.ShortPropertyDef) ToFloatFunction(io.aklivity.zilla.runtime.engine.Configuration.ToFloatFunction) DoublePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.DoublePropertyDef) ToByteFunction(io.aklivity.zilla.runtime.engine.Configuration.ToByteFunction) ToLongFunction(java.util.function.ToLongFunction) Assert.assertEquals(org.junit.Assert.assertEquals) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) IntPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.IntPropertyDef) Test(org.junit.Test)

Example 3 with PropertyDef

use of io.aklivity.zilla.runtime.engine.Configuration.PropertyDef in project zilla by aklivity.

the class ConfigurationTest method shouldSupplyDefaultBooleanProperty.

@Test
public void shouldSupplyDefaultBooleanProperty() {
    ConfigurationDef configDef = new ConfigurationDef("scope");
    BooleanPropertyDef propertyDef = configDef.property("boolean.property.name", (Predicate<Configuration>) c -> true);
    Configuration config = new Configuration();
    assertTrue(propertyDef.getAsBoolean(config));
}
Also used : PropertyDef(io.aklivity.zilla.runtime.engine.Configuration.PropertyDef) Properties(java.util.Properties) IntPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.IntPropertyDef) BooleanPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BooleanPropertyDef) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) Predicate(java.util.function.Predicate) FloatPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.FloatPropertyDef) ToIntFunction(java.util.function.ToIntFunction) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) LongPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.LongPropertyDef) ToCharFunction(io.aklivity.zilla.runtime.engine.Configuration.ToCharFunction) BytePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BytePropertyDef) CharPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.CharPropertyDef) ToDoubleFunction(java.util.function.ToDoubleFunction) ToShortFunction(io.aklivity.zilla.runtime.engine.Configuration.ToShortFunction) ShortPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.ShortPropertyDef) ToFloatFunction(io.aklivity.zilla.runtime.engine.Configuration.ToFloatFunction) DoublePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.DoublePropertyDef) ToByteFunction(io.aklivity.zilla.runtime.engine.Configuration.ToByteFunction) ToLongFunction(java.util.function.ToLongFunction) Assert.assertEquals(org.junit.Assert.assertEquals) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) BooleanPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BooleanPropertyDef) Test(org.junit.Test)

Example 4 with PropertyDef

use of io.aklivity.zilla.runtime.engine.Configuration.PropertyDef in project zilla by aklivity.

the class ConfigurationTest method shouldSupplyDefaultLongProperty.

@Test
public void shouldSupplyDefaultLongProperty() {
    ConfigurationDef configDef = new ConfigurationDef("scope");
    LongPropertyDef propertyDef = configDef.property("long.property.name", (ToLongFunction<Configuration>) c -> 1234L);
    Configuration config = new Configuration();
    assertEquals(1234L, propertyDef.getAsLong(config));
}
Also used : PropertyDef(io.aklivity.zilla.runtime.engine.Configuration.PropertyDef) Properties(java.util.Properties) IntPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.IntPropertyDef) BooleanPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BooleanPropertyDef) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) Predicate(java.util.function.Predicate) FloatPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.FloatPropertyDef) ToIntFunction(java.util.function.ToIntFunction) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) LongPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.LongPropertyDef) ToCharFunction(io.aklivity.zilla.runtime.engine.Configuration.ToCharFunction) BytePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BytePropertyDef) CharPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.CharPropertyDef) ToDoubleFunction(java.util.function.ToDoubleFunction) ToShortFunction(io.aklivity.zilla.runtime.engine.Configuration.ToShortFunction) ShortPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.ShortPropertyDef) ToFloatFunction(io.aklivity.zilla.runtime.engine.Configuration.ToFloatFunction) DoublePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.DoublePropertyDef) ToByteFunction(io.aklivity.zilla.runtime.engine.Configuration.ToByteFunction) ToLongFunction(java.util.function.ToLongFunction) Assert.assertEquals(org.junit.Assert.assertEquals) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) LongPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.LongPropertyDef) Test(org.junit.Test)

Example 5 with PropertyDef

use of io.aklivity.zilla.runtime.engine.Configuration.PropertyDef in project zilla by aklivity.

the class ConfigurationTest method shouldSupplyDefaultByteProperty.

@Test
public void shouldSupplyDefaultByteProperty() {
    ConfigurationDef configDef = new ConfigurationDef("scope");
    BytePropertyDef propertyDef = configDef.property("byte.property.name", (ToByteFunction<Configuration>) c -> Byte.decode("0x7f"));
    Configuration config = new Configuration();
    assertEquals(Byte.MAX_VALUE, propertyDef.getAsByte(config));
}
Also used : PropertyDef(io.aklivity.zilla.runtime.engine.Configuration.PropertyDef) Properties(java.util.Properties) IntPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.IntPropertyDef) BooleanPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BooleanPropertyDef) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) Predicate(java.util.function.Predicate) FloatPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.FloatPropertyDef) ToIntFunction(java.util.function.ToIntFunction) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) LongPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.LongPropertyDef) ToCharFunction(io.aklivity.zilla.runtime.engine.Configuration.ToCharFunction) BytePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BytePropertyDef) CharPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.CharPropertyDef) ToDoubleFunction(java.util.function.ToDoubleFunction) ToShortFunction(io.aklivity.zilla.runtime.engine.Configuration.ToShortFunction) ShortPropertyDef(io.aklivity.zilla.runtime.engine.Configuration.ShortPropertyDef) ToFloatFunction(io.aklivity.zilla.runtime.engine.Configuration.ToFloatFunction) DoublePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.DoublePropertyDef) ToByteFunction(io.aklivity.zilla.runtime.engine.Configuration.ToByteFunction) ToLongFunction(java.util.function.ToLongFunction) Assert.assertEquals(org.junit.Assert.assertEquals) ConfigurationDef(io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef) BytePropertyDef(io.aklivity.zilla.runtime.engine.Configuration.BytePropertyDef) Test(org.junit.Test)

Aggregations

BooleanPropertyDef (io.aklivity.zilla.runtime.engine.Configuration.BooleanPropertyDef)8 BytePropertyDef (io.aklivity.zilla.runtime.engine.Configuration.BytePropertyDef)8 CharPropertyDef (io.aklivity.zilla.runtime.engine.Configuration.CharPropertyDef)8 ConfigurationDef (io.aklivity.zilla.runtime.engine.Configuration.ConfigurationDef)8 DoublePropertyDef (io.aklivity.zilla.runtime.engine.Configuration.DoublePropertyDef)8 FloatPropertyDef (io.aklivity.zilla.runtime.engine.Configuration.FloatPropertyDef)8 IntPropertyDef (io.aklivity.zilla.runtime.engine.Configuration.IntPropertyDef)8 LongPropertyDef (io.aklivity.zilla.runtime.engine.Configuration.LongPropertyDef)8 PropertyDef (io.aklivity.zilla.runtime.engine.Configuration.PropertyDef)8 ShortPropertyDef (io.aklivity.zilla.runtime.engine.Configuration.ShortPropertyDef)8 ToByteFunction (io.aklivity.zilla.runtime.engine.Configuration.ToByteFunction)8 ToCharFunction (io.aklivity.zilla.runtime.engine.Configuration.ToCharFunction)8 ToFloatFunction (io.aklivity.zilla.runtime.engine.Configuration.ToFloatFunction)8 ToShortFunction (io.aklivity.zilla.runtime.engine.Configuration.ToShortFunction)8 Properties (java.util.Properties)8 Predicate (java.util.function.Predicate)8 ToDoubleFunction (java.util.function.ToDoubleFunction)8 ToIntFunction (java.util.function.ToIntFunction)8 ToLongFunction (java.util.function.ToLongFunction)8 Assert.assertEquals (org.junit.Assert.assertEquals)8