Java Code Examples for com.github.tomakehurst.wiremock.stubbing.StubMapping#setMetadata()

The following examples show how to use com.github.tomakehurst.wiremock.stubbing.StubMapping#setMetadata() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BasicMappingBuilder.java    From spring-cloud-contract with Apache License 2.0 6 votes vote down vote up
@Override
public StubMapping build() {
	if (this.scenarioName == null && (this.requiredScenarioState != null
			|| this.newScenarioState != null)) {
		throw new IllegalStateException(
				"Scenario name must be specified to require or set a new scenario state");
	}
	RequestPattern requestPattern = this.requestPatternBuilder.build();
	ResponseDefinition response = (this.responseDefBuilder != null
			? this.responseDefBuilder : aResponse()).build();
	StubMapping mapping = new StubMapping(requestPattern, response);
	mapping.setPriority(this.priority);
	mapping.setScenarioName(this.scenarioName);
	mapping.setRequiredScenarioState(this.requiredScenarioState);
	mapping.setNewScenarioState(this.newScenarioState);
	mapping.setUuid(this.id);
	mapping.setName(this.name);
	mapping.setPersistent(this.isPersistent);
	mapping.setPostServeActions(
			this.postServeActions.isEmpty() ? null : this.postServeActions);
	mapping.setMetadata(this.metadata);
	return mapping;
}
 
Example 2
Source File: IronTestUtils.java    From irontest with Apache License 2.0 5 votes vote down vote up
/**
 * Create (clone) a new instance out of the stub spec, with UUID generated for the instance.
 * The instance also has the ironTestId as metadata.
 * The spec is not changed.
 * @param spec
 * @return
 */
public static StubMapping createStubInstance(long ironTestId, short ironTestNumber, StubMapping spec) {
    StubMapping stubInstance = StubMapping.buildFrom(StubMapping.buildJsonStringFor(spec));
    stubInstance.setMetadata(metadata()
            .attr(WIREMOCK_STUB_METADATA_ATTR_NAME_IRON_TEST_ID, ironTestId)
            .attr(WIREMOCK_STUB_METADATA_ATTR_NAME_IRON_TEST_NUMBER, ironTestNumber)
            .build());
    stubInstance.setDirty(false);
    return stubInstance;
}