Search in sources :

Example 46 with Any

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

the class MessageMismatch method unpackActual.

/**
 * Obtains actual value as a {@code Message} from the passed mismatch.
 *
 * @throws RuntimeException if the passed instance represent a mismatch of
 *                          non-{@code Message} values
 */
public static Message unpackActual(ValueMismatch mismatch) {
    checkNotNull(mismatch);
    final Any any = mismatch.getActual();
    final Message result = unpack(any);
    return result;
}
Also used : Message(com.google.protobuf.Message) Any(com.google.protobuf.Any)

Example 47 with Any

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

the class MessageMismatch method unpackExpected.

/**
 * Obtains expected value as a {@code Message} from the passed mismatch.
 *
 * @throws RuntimeException if the passed instance represent a mismatch of
 *                          non-{@code Message} values
 */
public static Message unpackExpected(ValueMismatch mismatch) {
    checkNotNull(mismatch);
    final Any any = mismatch.getExpected();
    final Message result = unpack(any);
    return result;
}
Also used : Message(com.google.protobuf.Message) Any(com.google.protobuf.Any)

Example 48 with Any

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

the class StringMismatch method unpackExpected.

/**
 * Obtains expected string from the passed mismatch.
 *
 * @throws RuntimeException if the passed instance represent a mismatch of non-string values
 */
public static String unpackExpected(ValueMismatch mismatch) {
    checkNotNull(mismatch);
    final Any expected = mismatch.getExpected();
    return unpacked(expected);
}
Also used : TypeConverter.toAny(io.spine.protobuf.TypeConverter.toAny) Any(com.google.protobuf.Any)

Example 49 with Any

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

the class Rejections method createRejection.

/**
 * Creates a new {@code Rejection} instance.
 *
 * @param messageOrAny the rejection message or {@code Any} containing the message
 * @param command      the {@code Command}, which triggered the rejection.
 * @return created rejection instance
 */
public static Rejection createRejection(Message messageOrAny, Command command) {
    checkNotNull(messageOrAny);
    checkNotNull(command);
    final Any packedMessage = pack(messageOrAny);
    final RejectionContext context = RejectionContext.newBuilder().setCommand(command).build();
    final Rejection result = Rejection.newBuilder().setMessage(packedMessage).setContext(context).build();
    return result;
}
Also used : Any(com.google.protobuf.Any)

Example 50 with Any

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

the class Rejections method toRejection.

/**
 * Converts this {@code ThrowableMessage} into {@link Rejection}.
 *
 * @param command the command which caused the rejection
 */
public static Rejection toRejection(ThrowableMessage throwable, Command command) {
    checkNotNull(throwable);
    checkNotNull(command);
    final Message rejectionMessage = throwable.getMessageThrown();
    final Any packedState = pack(rejectionMessage);
    final RejectionContext context = createContext(throwable, command);
    final RejectionId id = generateId(command.getId());
    final Rejection.Builder builder = Rejection.newBuilder().setId(id).setMessage(packedState).setContext(context);
    return builder.build();
}
Also used : ThrowableMessage(io.spine.base.ThrowableMessage) Message(com.google.protobuf.Message) Any(com.google.protobuf.Any)

Aggregations

Any (com.google.protobuf.Any)155 Test (org.junit.Test)44 Message (com.google.protobuf.Message)30 TypeConverter.toAny (io.spine.protobuf.TypeConverter.toAny)27 EntityRecord (io.spine.server.entity.EntityRecord)24 TypeUrl (io.spine.type.TypeUrl)15 Version (io.spine.core.Version)11 Customer (io.spine.test.commandservice.customer.Customer)11 GivenVersion (io.spine.core.given.GivenVersion)9 EntityRecordWithColumns (io.spine.server.entity.storage.EntityRecordWithColumns)8 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)8 CustomerId (io.spine.test.commandservice.customer.CustomerId)8 FieldMask (com.google.protobuf.FieldMask)7 Query (io.spine.client.Query)7 Project (io.spine.test.storage.Project)7 EntityId (io.spine.client.EntityId)6 QueryResponse (io.spine.client.QueryResponse)6 Ack (io.spine.core.Ack)6 Command (io.spine.core.Command)6 EntityFilters (io.spine.client.EntityFilters)5