io.github.microcks.jenkins.plugin.MicrocksTester Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of microcks-jenkins-plugin Show documentation
Show all versions of microcks-jenkins-plugin Show documentation
Microcks: easy mocks for your microservices - Jenkins Plugin
The newest version!
/*
* Licensed to Laurent Broudoux (the "Author") under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Author licenses this
* file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package io.github.microcks.jenkins.plugin;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.github.microcks.jenkins.plugin.model.GlobalConfig;
import io.github.microcks.jenkins.plugin.model.IMicrocksTester;
import hudson.Extension;
import hudson.tasks.Builder;
import org.kohsuke.stapler.DataBoundConstructor;
import java.util.*;
import java.util.Map.Entry;
/**
* @author laurent
*/
public class MicrocksTester extends TimedMicrocksBaseStep implements IMicrocksTester {
protected final String serviceId;
protected final String testEndpoint;
protected final String runnerType;
protected final String secretName;
protected final String operationsHeaders;
// Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
@DataBoundConstructor
public MicrocksTester(String server, String serviceId, String testEndpoint, String runnerType, String secretName,
String operationsHeaders, String verbose, String waitTime, String waitUnit) {
super(server, verbose, waitTime, waitUnit);
this.serviceId = serviceId != null ? serviceId.trim() : null;
this.testEndpoint = testEndpoint != null ? testEndpoint.trim() : null;
this.runnerType = runnerType != null ? runnerType.trim() : null;
this.secretName = secretName != null ? secretName.trim() : null;
this.operationsHeaders = operationsHeaders != null ? operationsHeaders.trim() : null;
}
@Override
public String getServiceId() {
return serviceId;
}
@Override
public String getTestEndpoint() {
return testEndpoint;
}
@Override
public String getRunnerType() {
return runnerType;
}
@Override
public String getSecretName() {
return secretName;
}
@Override
public Map>> getOperationsHeaders() {
Map>> results = null;
if (operationsHeaders != null && !operationsHeaders.isEmpty()) {
// Add some Jackson parsing and mapping here.
ObjectMapper mapper = new ObjectMapper();
try {
JsonNode rootNode = mapper.readTree(this.operationsHeaders);
// If we've got an object, that's a good start! Initialize results.
if (rootNode.isObject()) {
results = new HashMap<>();
Iterator> operationNodes = rootNode.fields();
while (operationNodes.hasNext()) {
Entry operationNode = operationNodes.next();
if (operationNode.getValue().isArray()) {
List © 2015 - 2025 Weber Informatics LLC | Privacy Policy