All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.zeebe.test.broker.protocol.commandapi.ExecuteCommandRequestBuilder Maven / Gradle / Ivy

There is a newer version: 1.0.0-alpha7
Show newest version
/*
 * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under
 * one or more contributor license agreements. See the NOTICE file distributed
 * with this work for additional information regarding copyright ownership.
 * Licensed under the Zeebe Community License 1.0. You may not use this file
 * except in compliance with the Zeebe Community License 1.0.
 */
package io.zeebe.test.broker.protocol.commandapi;

import io.zeebe.protocol.record.ValueType;
import io.zeebe.protocol.record.intent.Intent;
import io.zeebe.test.broker.protocol.MsgPackHelper;
import io.zeebe.test.util.collection.MapBuilder;
import io.zeebe.transport.ClientTransport;
import io.zeebe.util.buffer.BufferWriter;
import java.util.Map;

public final class ExecuteCommandRequestBuilder {
  protected final ExecuteCommandRequest request;

  public ExecuteCommandRequestBuilder(
      final ClientTransport output, final String targetAddress, final MsgPackHelper msgPackHelper) {
    this.request = new ExecuteCommandRequest(output, targetAddress, msgPackHelper);
  }

  public ExecuteCommandResponse sendAndAwait() {
    return send().await();
  }

  public ExecuteCommandRequest send() {
    return request.send();
  }

  public ExecuteCommandRequestBuilder partitionId(final int partitionId) {
    request.partitionId(partitionId);
    return this;
  }

  public ExecuteCommandRequestBuilder key(final long key) {
    request.key(key);
    return this;
  }

  public ExecuteCommandRequestBuilder type(final ValueType valueType, final Intent intent) {
    request.valueType(valueType);
    request.intent(intent);
    return this;
  }

  public ExecuteCommandRequestBuilder intent(final Intent intent) {
    request.intent(intent);
    return this;
  }

  public ExecuteCommandRequestBuilder command(final Map command) {
    request.command(command);
    return this;
  }

  public ExecuteCommandRequestBuilder command(final BufferWriter command) {
    request.command(command);
    return this;
  }

  public MapBuilder command() {
    final MapBuilder mapBuilder =
        new MapBuilder<>(this, this::command);
    return mapBuilder;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy