Search in sources :

Example 11 with FieldDescriptor

use of com.google.protobuf.Descriptors.FieldDescriptor in project core-java by SpineEventEngine.

the class FieldShould method pass_the_null_tolerance_check.

@Test
public void pass_the_null_tolerance_check() {
    final FieldDescriptor defaultFieldDescriptor = StringValue.getDefaultInstance().getDescriptorForType().getFields().get(0);
    new NullPointerTester().setDefault(TypeUrl.class, TypeUrl.of(StringValue.class)).setDefault(FieldDescriptor.class, defaultFieldDescriptor).testAllPublicStaticMethods(Messages.class);
}
Also used : NullPointerTester(com.google.common.testing.NullPointerTester) MessageWithStringValue(io.spine.test.messages.MessageWithStringValue) StringValue(com.google.protobuf.StringValue) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor) Test(org.junit.Test)

Example 12 with FieldDescriptor

use of com.google.protobuf.Descriptors.FieldDescriptor in project core-java by SpineEventEngine.

the class FieldValidatorFactoryShould method create_Boolean_field_validator.

@Test
public void create_Boolean_field_validator() {
    final FieldDescriptor field = BoolValue.getDescriptor().getFields().get(0);
    final FieldValidator validator = FieldValidatorFactory.create(field, new Object(), FIELD_PATH);
    assertTrue(validator instanceof BooleanFieldValidator);
}
Also used : ByteStringFieldValidator(io.spine.validate.ByteStringFieldValidator) FloatFieldValidator(io.spine.validate.FloatFieldValidator) StringFieldValidator(io.spine.validate.StringFieldValidator) LongFieldValidator(io.spine.validate.LongFieldValidator) BooleanFieldValidator(io.spine.validate.BooleanFieldValidator) BooleanFieldValidator(io.spine.validate.BooleanFieldValidator) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor) Test(org.junit.Test)

Example 13 with FieldDescriptor

use of com.google.protobuf.Descriptors.FieldDescriptor in project core-java by SpineEventEngine.

the class FieldValidatorFactoryShould method create_String_field_validator.

@Test
public void create_String_field_validator() {
    final FieldDescriptor field = StringValue.getDescriptor().getFields().get(0);
    final FieldValidator validator = FieldValidatorFactory.create(field, "", FIELD_PATH);
    assertTrue(validator instanceof StringFieldValidator);
}
Also used : ByteStringFieldValidator(io.spine.validate.ByteStringFieldValidator) FloatFieldValidator(io.spine.validate.FloatFieldValidator) StringFieldValidator(io.spine.validate.StringFieldValidator) LongFieldValidator(io.spine.validate.LongFieldValidator) BooleanFieldValidator(io.spine.validate.BooleanFieldValidator) ByteStringFieldValidator(io.spine.validate.ByteStringFieldValidator) StringFieldValidator(io.spine.validate.StringFieldValidator) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor) Test(org.junit.Test)

Example 14 with FieldDescriptor

use of com.google.protobuf.Descriptors.FieldDescriptor in project core-java by SpineEventEngine.

the class FieldValidatorFactoryShould method create_float_field_validator.

@Test
public void create_float_field_validator() {
    final FieldDescriptor field = FloatValue.getDescriptor().getFields().get(0);
    final FieldValidator validator = FieldValidatorFactory.create(field, 0, FIELD_PATH);
    assertTrue(validator instanceof FloatFieldValidator);
}
Also used : ByteStringFieldValidator(io.spine.validate.ByteStringFieldValidator) FloatFieldValidator(io.spine.validate.FloatFieldValidator) StringFieldValidator(io.spine.validate.StringFieldValidator) LongFieldValidator(io.spine.validate.LongFieldValidator) BooleanFieldValidator(io.spine.validate.BooleanFieldValidator) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor) FloatFieldValidator(io.spine.validate.FloatFieldValidator) Test(org.junit.Test)

Example 15 with FieldDescriptor

use of com.google.protobuf.Descriptors.FieldDescriptor in project core-java by SpineEventEngine.

the class FieldValidatorFactoryShould method create_message_field_validator.

@Test
public void create_message_field_validator() {
    final FieldDescriptor field = RequiredMsgFieldValue.getDescriptor().getFields().get(0);
    final FieldValidator validator = FieldValidatorFactory.create(field, StringValue.getDefaultInstance(), FIELD_PATH);
    assertTrue(validator instanceof MessageFieldValidator);
}
Also used : ByteStringFieldValidator(io.spine.validate.ByteStringFieldValidator) FloatFieldValidator(io.spine.validate.FloatFieldValidator) StringFieldValidator(io.spine.validate.StringFieldValidator) LongFieldValidator(io.spine.validate.LongFieldValidator) BooleanFieldValidator(io.spine.validate.BooleanFieldValidator) FieldDescriptor(com.google.protobuf.Descriptors.FieldDescriptor) Test(org.junit.Test)

Aggregations

FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)45 Descriptor (com.google.protobuf.Descriptors.Descriptor)18 Test (org.junit.Test)14 EnumDescriptor (com.google.protobuf.Descriptors.EnumDescriptor)11 EnumValueDescriptor (com.google.protobuf.Descriptors.EnumValueDescriptor)11 BooleanFieldValidator (io.spine.validate.BooleanFieldValidator)9 ByteStringFieldValidator (io.spine.validate.ByteStringFieldValidator)9 FloatFieldValidator (io.spine.validate.FloatFieldValidator)9 LongFieldValidator (io.spine.validate.LongFieldValidator)9 StringFieldValidator (io.spine.validate.StringFieldValidator)9 TypicalData (protos.TypicalData)5 ArrayList (java.util.ArrayList)4 ByteString (com.google.protobuf.ByteString)3 ExtensionRegistry (com.google.protobuf.ExtensionRegistry)3 ValidationResult (io.spine.server.event.enrich.ReferenceValidator.ValidationResult)3 Map (java.util.Map)3 GeneratedMessage (com.google.protobuf.GeneratedMessage)2 Collection (java.util.Collection)2 TypicalDataMessage (protos.TypicalDataMessage)2 ImageAnnotatorClient (com.google.cloud.vision.spi.v1.ImageAnnotatorClient)1