Search in sources :

Example 6 with UserId

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

the class TestsShould method create_UserId_by_string.

@Test
public void create_UserId_by_string() {
    final String testIdString = "12345";
    final UserId userId = newUserId(testIdString);
    final UserId expected = UserId.newBuilder().setValue(testIdString).build();
    assertEquals(expected, userId);
}
Also used : UserId(io.spine.users.UserId) Tests.newUserId(io.spine.test.Tests.newUserId) Test(org.junit.Test)

Example 7 with UserId

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

the class StringifiersShould method convert_from_message_to_json.

@Test
public void convert_from_message_to_json() {
    final String idValue = newUuid();
    final UserId userId = UserId.newBuilder().setValue(idValue).build();
    final Stringifier<UserId> messageStringifier = StringifierRegistry.getStringifier(UserId.class);
    final String convertedMessage = messageStringifier.convert(userId);
    assertNotNull(convertedMessage);
    assertTrue(convertedMessage.contains(idValue));
}
Also used : UserId(io.spine.users.UserId) Identifiers.idToString(io.spine.base.Identifiers.idToString) Test(org.junit.Test)

Example 8 with UserId

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

the class JsonShould method parse_from_json.

@Test
public void parse_from_json() {
    final String idValue = newUuid();
    final String jsonMessage = String.format("{value:%s}", idValue);
    final UserId userId = fromJson(jsonMessage, UserId.class);
    assertNotNull(userId);
    assertEquals(idValue, userId.getValue());
}
Also used : UserId(io.spine.users.UserId) 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