Search in sources :

Example 1 with UserId

use of io.spine.users.UserId in project core-java by SpineEventEngine.

the class JsonShould method print_to_compact_json.

@Test
public void print_to_compact_json() {
    final String idValue = newUuid();
    final UserId userId = UserId.newBuilder().setValue(idValue).build();
    final String result = toCompactJson(userId);
    assertFalse(result.isEmpty());
    assertFalse(result.contains(System.lineSeparator()));
}
Also used : UserId(io.spine.users.UserId) Test(org.junit.Test)

Example 2 with UserId

use of io.spine.users.UserId in project core-java by SpineEventEngine.

the class AnyPackerShould method unpack_spine_message_from_Any.

@Test
public void unpack_spine_message_from_Any() {
    final Any any = AnyPacker.pack(spineMsg);
    final UserId actual = AnyPacker.unpack(any);
    assertEquals(spineMsg, actual);
}
Also used : UserId(io.spine.users.UserId) Tests.newUserId(io.spine.test.Tests.newUserId) Any(com.google.protobuf.Any) Test(org.junit.Test)

Example 3 with UserId

use of io.spine.users.UserId in project core-java by SpineEventEngine.

the class CommandFactoryShould method create_command_context.

@Test
public void create_command_context() {
    final TenantId tenantId = newTenantUuid();
    final UserId userId = newUserUuid();
    final ZoneOffset zoneOffset = ZoneOffsets.ofHours(-3);
    final int targetVersion = 100500;
    final CommandContext commandContext = CommandFactory.createContext(tenantId, userId, zoneOffset, targetVersion);
    final ActorContext actorContext = commandContext.getActorContext();
    assertEquals(tenantId, actorContext.getTenantId());
    assertEquals(userId, actorContext.getActor());
    assertEquals(zoneOffset, actorContext.getZoneOffset());
    assertEquals(targetVersion, commandContext.getTargetVersion());
}
Also used : TenantId(io.spine.users.TenantId) CommandContext(io.spine.base.CommandContext) UserId(io.spine.users.UserId) ZoneOffset(io.spine.time.ZoneOffset) ActorContext(io.spine.base.ActorContext) Test(org.junit.Test)

Example 4 with UserId

use of io.spine.users.UserId in project core-java by SpineEventEngine.

the class TestCommandContextFactory method createCommandContext.

/** Creates a new {@link CommandContext} instance. */
public static CommandContext createCommandContext() {
    final UserId userId = newUserId(newUuid());
    final Timestamp now = getCurrentTime();
    return createCommandContext(userId, now);
}
Also used : UserId(io.spine.users.UserId) Tests.newUserId(io.spine.test.Tests.newUserId) Timestamp(com.google.protobuf.Timestamp)

Example 5 with UserId

use of io.spine.users.UserId in project core-java by SpineEventEngine.

the class StringifiersShould method convert_from_json_to_message.

@Test
public void convert_from_json_to_message() {
    final Stringifier<UserId> messageStringifier = StringifierRegistry.getStringifier(UserId.class);
    final String idValue = newUuid();
    final UserId result = messageStringifier.reverse().convert("{value:" + idValue + '}');
    assertNotNull(result);
    assertEquals(idValue, result.getValue());
}
Also used : UserId(io.spine.users.UserId) Identifiers.idToString(io.spine.base.Identifiers.idToString) Test(org.junit.Test)

Aggregations

UserId (io.spine.users.UserId)8 Test (org.junit.Test)7 Tests.newUserId (io.spine.test.Tests.newUserId)3 Identifiers.idToString (io.spine.base.Identifiers.idToString)2 Any (com.google.protobuf.Any)1 Timestamp (com.google.protobuf.Timestamp)1 ActorContext (io.spine.base.ActorContext)1 CommandContext (io.spine.base.CommandContext)1 ZoneOffset (io.spine.time.ZoneOffset)1 TenantId (io.spine.users.TenantId)1