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

io.tracee.SimpleTraceeBackend Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package io.tracee;

import io.tracee.configuration.TraceeFilterConfiguration;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * A testhelper for TraceeBackend dependent tests.
 */
public class SimpleTraceeBackend implements TraceeBackend {


	private Map valuesBeforeLastClear = Collections.emptyMap();

	private Map backendValues = new HashMap();

	public static SimpleTraceeBackend createNonLoggingAllPermittingBackend() {
		return new SimpleTraceeBackend(new PermitAllTraceeFilterConfiguration());
	}

	public SimpleTraceeBackend(TraceeFilterConfiguration configuration) {
		this.configuration = configuration;
	}

	private final TraceeFilterConfiguration configuration;

	/**
	 * {@inheritDoc}
	 * 
This implementation ignores profiles and always uses the default configuration. */ @Override public TraceeFilterConfiguration getConfiguration(String profileName) { return configuration; } @Override public TraceeFilterConfiguration getConfiguration() { return configuration; } @Override public boolean containsKey(String key) { return backendValues.containsKey(key); } @Override public String get(String key) { return backendValues.get(key); } @Override public int size() { return backendValues.size(); } @Override public void clear() { this.valuesBeforeLastClear = new HashMap(this.copyToMap()); backendValues.clear(); } @Override public boolean isEmpty() { return backendValues.isEmpty(); } @Override public void put(String key, String value) { backendValues.put(key, value); } @Override public void putAll(Map m) { backendValues.putAll(m); } @Override public Map copyToMap() { return new HashMap(backendValues); } @Override public void remove(String key) { backendValues.remove(key); } @Override public String getInvocationId() { return get(TraceeConstants.INVOCATION_ID_KEY); } @Override public String getSessionId() { return get(TraceeConstants.SESSION_ID_KEY); } public Map getValuesBeforeLastClear() { return valuesBeforeLastClear; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy