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

com.neotys.neoload.model.v3.project.userpath.Loop Maven / Gradle / Ivy

package com.neotys.neoload.model.v3.project.userpath;

import java.util.List;
import java.util.stream.Stream;

import javax.validation.Valid;
import javax.validation.constraints.Pattern;

import org.immutables.value.Value;
import org.immutables.value.Value.Style.ValidationMethod;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.neotys.neoload.model.v3.binding.serializer.StepsDeserializer;
import com.neotys.neoload.model.v3.project.Element;
import com.neotys.neoload.model.v3.validation.constraints.RequiredCheck;
import com.neotys.neoload.model.v3.validation.groups.NeoLoad;

@JsonInclude(value=Include.NON_EMPTY)
@JsonPropertyOrder({Element.DESCRIPTION, Loop.COUNT, Loop.STEPS })
@JsonDeserialize(as = ImmutableLoop.class)
@Value.Immutable
@Value.Style(validationMethod = ValidationMethod.NONE)
public interface Loop extends Step {

	String DEFAULT_NAME = "loop";
	String STEPS = "steps";
	String COUNT = "count";

	@Value.Default
	@RequiredCheck(groups = {NeoLoad.class})
	default String getName() {
		return DEFAULT_NAME;
	}


	@JsonProperty(COUNT)
	@RequiredCheck(groups = {NeoLoad.class})
	@Valid
	@Pattern(regexp = "(\\d+|\\$\\{\\w+\\})", groups = {NeoLoad.class})
	String getCount();

	@JsonProperty(STEPS)
	@RequiredCheck(groups={NeoLoad.class})
	@Valid
	@JsonDeserialize(using = StepsDeserializer.class)
	List getSteps();

	@Override
	default Stream flattened() {
		return Stream.concat(Stream.of(this), getSteps().stream().flatMap(Step::flattened));
	}

	class Builder extends ImmutableLoop.Builder {}
	static Builder builder() {
		return new Builder();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy