Search in sources :

Example 1 with TypeUrl

use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.

the class KnownTypesShould method return_proto_type_url_by_proto_type_name.

@Test
public void return_proto_type_url_by_proto_type_name() {
    final TypeUrl typeUrlExpected = TypeUrl.from(StringValue.getDescriptor());
    final TypeUrl typeUrlActual = KnownTypes.getTypeUrl(typeUrlExpected.getTypeName());
    assertEquals(typeUrlExpected, typeUrlActual);
}
Also used : TypeUrl(io.spine.type.TypeUrl) Test(org.junit.Test)

Example 2 with TypeUrl

use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.

the class KnownTypesShould method return_java_inner_class_name_by_proto_type_url.

@Test
public void return_java_inner_class_name_by_proto_type_url() {
    final TypeUrl typeUrl = TypeUrl.from(CommandContext.Schedule.getDescriptor());
    final ClassName className = KnownTypes.getClassName(typeUrl);
    assertEquals(ClassName.of(CommandContext.Schedule.class), className);
}
Also used : ClassName(io.spine.type.ClassName) TypeUrl(io.spine.type.TypeUrl) Test(org.junit.Test)

Example 3 with TypeUrl

use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.

the class KnownTypesShould method return_all_types_under_certain_package.

@Test
public void return_all_types_under_certain_package() {
    final TypeUrl taskId = TypeUrl.from(TaskId.getDescriptor());
    final TypeUrl taskName = TypeUrl.from(TaskName.getDescriptor());
    final TypeUrl task = TypeUrl.from(Task.getDescriptor());
    final String packageName = "spine.test.types";
    final Collection<TypeUrl> packageTypes = getAllFromPackage(packageName);
    assertSize(3, packageTypes);
    assertTrue(packageTypes.containsAll(Arrays.asList(taskId, taskName, task)));
}
Also used : TypeUrl(io.spine.type.TypeUrl) Test(org.junit.Test)

Example 4 with TypeUrl

use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.

the class KnownTypesShould method return_proto_type_url_by_java_class_name.

@Test
public void return_proto_type_url_by_java_class_name() {
    final ClassName className = ClassName.of(Command.class);
    final TypeUrl typeUrl = KnownTypes.getTypeUrl(className);
    assertEquals(TypeUrl.from(Command.getDescriptor()), typeUrl);
}
Also used : ClassName(io.spine.type.ClassName) TypeUrl(io.spine.type.TypeUrl) Test(org.junit.Test)

Example 5 with TypeUrl

use of io.spine.type.TypeUrl in project core-java by SpineEventEngine.

the class KnownTypesShould method throw_exception_if_no_java_class_name_by_type_url.

@Test(expected = UnknownTypeException.class)
public void throw_exception_if_no_java_class_name_by_type_url() {
    final TypeUrl unexpectedUrl = TypeUrl.parse("prefix/unexpected.type");
    KnownTypes.getClassName(unexpectedUrl);
}
Also used : TypeUrl(io.spine.type.TypeUrl) Test(org.junit.Test)

Aggregations

TypeUrl (io.spine.type.TypeUrl)37 Any (com.google.protobuf.Any)12 Test (org.junit.Test)11 EntityRecord (io.spine.server.entity.EntityRecord)7 Message (com.google.protobuf.Message)6 StandStorage (io.spine.server.stand.StandStorage)4 EntityRecordWithColumns (io.spine.server.entity.storage.EntityRecordWithColumns)3 ClassName (io.spine.type.ClassName)3 TypeName (io.spine.type.TypeName)3 Descriptors (com.google.protobuf.Descriptors)2 Version (io.spine.base.Version)2 Query (io.spine.client.Query)2 BoundedContext (io.spine.server.BoundedContext)2 StandTestProjectionRepository (io.spine.server.stand.Given.StandTestProjectionRepository)2 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)2 Customer (io.spine.test.commandservice.customer.Customer)2 CustomerId (io.spine.test.commandservice.customer.CustomerId)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)1 CanIgnoreReturnValue (com.google.errorprone.annotations.CanIgnoreReturnValue)1