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

io.github.azagniotov.stubby4j.stubs.AbstractBuilder Maven / Gradle / Ivy

Go to download

A highly flexible & configurable tool for testing interactions of SOA applications with web services (REST, SOAP, WSDL etc.) over HTTP(S) protocol. It is an actual HTTP server (stubby4j uses embedded Jetty) that acts like a real web service, ready for consumption by your code. Allows stubbing of external systems with ease for integration testing

There is a newer version: 7.6.1
Show newest version
package io.github.azagniotov.stubby4j.stubs;


import io.github.azagniotov.stubby4j.yaml.ConfigurableYAMLProperty;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import static io.github.azagniotov.generics.TypeSafeConverter.as;

public abstract class AbstractBuilder {

    final Map fieldNameAndValues;

    AbstractBuilder() {
        this.fieldNameAndValues = new HashMap<>();
    }

     E getStaged(final Class clazzor, final ConfigurableYAMLProperty property, E defaultValue) {
        return fieldNameAndValues.containsKey(property) ? as(clazzor, fieldNameAndValues.get(property)) : defaultValue;
    }

    public void stage(final Optional fieldNameOptional, final Optional fieldValueOptional) {
        if (fieldNameOptional.isPresent() && fieldValueOptional.isPresent()) {
            fieldNameAndValues.put(fieldNameOptional.get(), fieldValueOptional.get());
        }
    }

    public abstract T build();
}