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

com.github.grzesiek_galezowski.test_environment.buffer.implementation.SynchronizedReceivedObjectBuffer Maven / Gradle / Ivy

There is a newer version: 1.2.5
Show newest version
package com.github.grzesiek_galezowski.test_environment.buffer.implementation;

import com.github.grzesiek_galezowski.test_environment.buffer.interfaces.Buffer;
import com.github.grzesiek_galezowski.test_environment.buffer.interfaces.BufferObserver;
import com.github.grzesiek_galezowski.test_environment.buffer.interfaces.ItemSubscriber;
import com.github.grzesiek_galezowski.test_environment.buffer.interfaces.MatchCountCondition;
import com.github.grzesiek_galezowski.test_environment.buffer.interfaces.Poll;
import lombok.Synchronized;
import org.assertj.core.api.Condition;

import java.time.Duration;

/**
 * Created by grzes on 09.07.2017.
 */
public class SynchronizedReceivedObjectBuffer implements Buffer {
  private Buffer innerBuffer;
  private BufferObserver observer;

  public SynchronizedReceivedObjectBuffer(
      final Buffer innerBuffer,
      final BufferObserver observer) {
    this.innerBuffer = innerBuffer;
    this.observer = observer;
  }

  @Override
  @Synchronized
  public void store(final T object) {
    innerBuffer.store(object);
  }

  @Override
  @Synchronized
  public void store(final T[] objects) {
    innerBuffer.store(objects);
  }

  @Override
  @Synchronized
  public void store(final Iterable objects) {
    innerBuffer.store(objects);
  }

  @Override
  @Synchronized()
  public void assertContains(final MatchCountCondition matchCountCondition, final Condition condition) {
    innerBuffer.assertContains(matchCountCondition, condition);
  }

  @Override
  @Synchronized
  public boolean contains(final MatchCountCondition matchCountCondition, final Condition condition) {
    return innerBuffer.contains(matchCountCondition, condition);
  }

  @Override
  @Synchronized
  public boolean isEmpty() {
    return innerBuffer.isEmpty();
  }

  @Override
  @Synchronized
  public void clearItems() {
    innerBuffer.clearItems();
  }

  @Override
  @Synchronized
  public void subscribeForItems(final ItemSubscriber subscriber) {
    innerBuffer.subscribeForItems(subscriber);
  }

  @Override
  @Synchronized
  public void subscribeFor(final Condition condition, final ItemSubscriber subscriber) {
    innerBuffer.subscribeFor(condition, subscriber);
  }

  @Override
  @Synchronized
  public Poll poll() {
    return AwaitilityPoll.on(this, observer);
  }

  @Override
  @Synchronized
  public Poll pollFor(final Duration duration) {
    return AwaitilityPoll.on(this, duration, observer);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy