

package io.spine.testing.core.given;

import io.spine.core.Enrichment;

import static io.spine.base.Identifier.newUuid;
import static io.spine.protobuf.AnyPacker.pack;
import static io.spine.protobuf.TypeConverter.toMessage;

/**
 * Factory methods to create {@code Enrichment} instances in test purposes.
 */
public final class GivenEnrichment {

    /** Prevents instantiation of this utility class. */
    private GivenEnrichment() {
    }

    /**
     * Creates a new {@link Enrichment} with one {@linkplain Enrichment#getContainer() attribute}.
     *
     * <p>An enrichment attribute is invalid and has random values.
     *
     * @return a new enrichment instance
     */
    public static Enrichment withOneAttribute() {
        var key = newUuid();
        var value = pack(toMessage(newUuid()));
        var result = Enrichment.newBuilder()
                .setContainer(Enrichment.Container.newBuilder()
                                      .putItems(key, value)
                                      .build())
                .build();
        return result;
    }
}
