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

co.verisoft.fw.xray.XrayJsonParameterObject Maven / Gradle / Ivy

Go to download

VeriSoft framework for testing web and mobile applications. junit 5 Module

The newest version!
package co.verisoft.fw.xray;
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 * 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.
 */

import co.verisoft.fw.utils.Builder;
import co.verisoft.fw.utils.JsonObject;
import lombok.ToString;
import org.jetbrains.annotations.Nullable;
import org.json.simple.JSONObject;

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

/**
 * Representation of Xray object - Parameter. This class follows the builder design pattern
* *
From Xray documentation:
* "parameter" object - parameters within iteration results
* * @author Nir Gallner * @see * Using Xray JSON format to import execution results - Parameter * @since 0.0.2 (Jan 2022) */ @ToString public class XrayJsonParameterObject extends XrayJsonFormat implements JsonObject { private final Map fields; public @Nullable String getName() { return fields.get("name"); } public @Nullable String getValue() { return fields.get("value"); } private XrayJsonParameterObject(XrayJsonParameterObjectBuilder builder) { this.fields = builder.fields; } @SuppressWarnings("unchecked") @Override public JSONObject asJsonObject() { JSONObject obj = new JSONObject(); if (this.getName() != null) obj.put("name", fields.get("name")); if (this.getValue() != null) obj.put("value", fields.get("value")); return obj; } @Override public String asString() { return this.asJsonObject().toJSONString(); } /** * Builder class for XrayInfoObject * * @author Nir Gallner * @since 0.0.2 (Jan 2022) */ @SuppressWarnings("rawtypes") @ToString public static class XrayJsonParameterObjectBuilder implements Builder { private final Map fields; public XrayJsonParameterObjectBuilder(XrayJsonParameterObject obj) { this.fields = obj.fields; } public XrayJsonParameterObjectBuilder() { this.fields = new HashMap<>(); } public XrayJsonParameterObjectBuilder name(String name) { this.fields.put("name", name); return this; } public XrayJsonParameterObjectBuilder value(String value) { this.fields.put("value", value); return this; } public XrayJsonParameterObject build() { XrayJsonParameterObject info = new XrayJsonParameterObject(this); validateXrayParameterObject(info); return info; } private void validateXrayParameterObject(XrayJsonParameterObject obj) { // TOOD: some validation code here } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy