Help Classes

Applies to ReadyAPI 3.54, last modified on September 23, 2024

Important notes:

  • These classes are not available in ReadyAPI 2.6 or later.

  • These classes are not available in SoapUI Open Source.

  • The VCS package contains a number of help classes related to the version control.

Enums

ActivationStatus

/**
* The status returned when trying to activate a VCS for a project.
*/

public enum ActivationStatus {

/**
* The VCS has been activated successfully for a specific project.
*/
SUCCESSFUL,

/**
* The VCS could not be activated for a specific project.
*/
FAILED
}

LockStatus

public enum LockStatus {
NOT_LOCKED,
LOCKED_BY_ME,
LOCKED_BY_OTHER
}

Exceptions

VcsIntegrationException

/**
* Thrown when an underlying VCS operation fails.
*/
public class VcsIntegrationException extends RuntimeException{

public VcsIntegrationException(String message) {
super(message);
}

public VcsIntegrationException(String message, Throwable cause) {
super(message, cause);
}
}

VcsPluginNotFoundException

public class VcsPluginNotFoundException extends Exception {
public VcsPluginNotFoundException(String message) {
super(message);
}
}

Classes

CommitResult

/**
* Representing the status returned when committing a number of {@link VcsUpdate}s to a remote repository.
*/
public class CommitResult {

public enum CommitStatus {
/**
* All the updates were successfully committed to the remote repository.
*/
SUCCESSFUL,

/**
* The updates could not be committed to the remote repository.
*/
FAILED,

/**
* Some of the updates were successfully committed to the remote repository, but not all.
*/
PARTIAL
}

private final CommitStatus commitStatus;

private final String resultMessage;

/**
* Creates CommitResult with a given status and additional information message.
*
* @param commitStatus - the status of the commit.
* @param resultMessage - an optional message describing the problem if the commit was not successful.
*/
public CommitResult(CommitStatus commitStatus, String resultMessage) {
this.commitStatus = commitStatus;
this.resultMessage = resultMessage;
}

public CommitStatus getCommitStatus() {
return commitStatus;
}

public String getResultMessage() {
return resultMessage;
}
}

HistoryEntry

import java.util.Date;

/**
* Represents an entry in the VCS history of a specific file.
*/
public class HistoryEntry {

private final String version;
private final Date date;
private final String author;
private final String commitMessage;

/**
* Creates a new VCS history entry.
*
* @param version - the VCS version identifier of this update.
* @param date - the date and time when this update was made.
* @param author - the author of this update.
* @param commitMessage - the commit message of this update.
*/
public HistoryEntry(String version, Date date, String author, String commitMessage) {
this.version = version;
this.date = date;
this.author = author;
this.commitMessage = commitMessage;
}

/**
* @return a string identifying this change in a VCS.
*/
public String getVersion() {
return version;
}

/**
* @return the date and time when this change was made.
*/
public Date getDate() {
return date;
}

/**
* @return the author of this commit.
*/
public String getAuthor() {
return author;
}

/**
* @return the message associated with this commit.
*/
public String getCommitMessage() {
return commitMessage;
}
}

ImportProjectFromVcsGui

import java.awt.Component;
import java.io.File;

public interface ImportProjectFromVcsGui {

/**
* A gui component with all the fields needed to perform the {@link #downloadProjectFiles(File)} operation,
* such as a repository URL, username, password, etc.
* @return a gui component or form with fields needed to download a project from a remote repository.
*/
Component getComponent();

/**
* Download all files from the selected repository into the path provided.
* @param emptyDirectory - an empty directory, to which files should be downloaded.
* @return basic information about the repository.
* @throws IllegalArgumentException if the file provided is not an empty directory.
* @throws VcsIntegrationException if there are problems with performing the VCS operation.
*/
VcsRepositoryInfo downloadProjectFiles(File emptyDirectory);

/**
* Validates all fields required to download the project files from the remote repository.
* @return true if all field values are valid, false otherwise.
*/
boolean isValidInput();
}

LockHandler (facade)

import java.io.File;

/**
* Defines a facade for VCS locking operations.
*/
public interface LockHandler {

/**
* Locks a file so that it can be changed exclusively by the lock holder.
*
* @param fileToLock - the file to lock.
* @return the status after the operation.
* @throws VcsIntegrationException if there is failure of communication with the remote repository.
*/
LockStatus lock(File fileToLock);

/**
* Releases the lock of a file so that others can modify it.
*
* @param fileToUnlock - the file to unlock.
* @return the status after the operation.
* @throws VcsIntegrationException if the file cannot be unlocked or there is failure of communication with the remote repository.
*/
LockStatus unlock(File fileToUnlock);


/**
* Get the locking status of a particular file.
*
* @param file - the file for which the lock status should be checked.
* @return a status object describing the locking status of the file.
* @throws VcsIntegrationException if there is failure of communication with the remote repository.
*/
LockStatus getLockStatusFor(File file);

/**
* Retrieve the name of the user holding the lock of a particular file.
*
* @param file - the file to check the status for.
* @return a string representing the user who has the lock for this file, or null if the file is not locked.
* @throws VcsIntegrationException if there is failure of communication with the remote repository.
*/
String getLockedBy(File file);
}

SimpleVcsIntegrationRegistry

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

/**
* Default implementation of VcsIntegrationRegistry.
*/
public class SimpleVcsIntegrationRegistry implements VcsIntegrationRegistry {

private static final SimpleVcsIntegrationRegistry instance = new SimpleVcsIntegrationRegistry();

private List<VcsIntegrationEntry> integrations = new ArrayList<>();

public static SimpleVcsIntegrationRegistry instance() {
return instance;
}

private SimpleVcsIntegrationRegistry() {
}

@Override
public void addVcsIntegration(String name, String description, VcsIntegration vcsIntegration) {
integrations.add(new VcsIntegrationEntry(name, description, vcsIntegration));
}

@Override
public Collection<VcsIntegrationEntry> getAllVcsIntegrations() {
return Collections.unmodifiableList(integrations);
}

@Override
public void removeVcsIntegration(VcsIntegration vcsIntegration) {
Iterator<VcsIntegrationEntry> iterator = integrations.iterator();
while (iterator.hasNext()) {
VcsIntegrationEntry vcsIntegrationEntry = iterator.next();
if (vcsIntegrationEntry.getIntegration() == vcsIntegration) {
iterator.remove();
break;
}
}
}

@Override
public VcsIntegration getVcsIntegrationByName(String name) throws VcsPluginNotFoundException {
for (VcsIntegrationEntry entry : integrations) {
if (entry.getName().equals(name)) {
return entry.getIntegration();
}
}
throw new VcsPluginNotFoundException("No VCS plugin found with name : "+ name);
}

}

VcsIntegrationEntry


/**
* Wrapper exposing metadata about VCS integration, as well as the integration itself.
*/
public class VcsIntegrationEntry {

private final String name;
private final String description;
private final VcsIntegration integration;

public VcsIntegrationEntry(String name, String description, VcsIntegration integration) {
this.name = name;
this.description = description;
this.integration = integration;
}

public String getName() {
return name;
}

public String getDescription() {
return description;
}

public VcsIntegration getIntegration() {
return integration;
}

@Override
public String toString() {
return name;
}
}

VcsRepositoryInfo


/**
* Encapsulates information about a VCS repository entered by a user.
*/
public class VcsRepositoryInfo {
private final String vcsName;
private final String repositoryIdentifier;

public VcsRepositoryInfo(String vcsName, String repositoryIdentifier) {
this.vcsName = vcsName;
this.repositoryIdentifier = repositoryIdentifier;
}

/**
* @return the name of the VCS plugin. Used to identify which plugin to use for a project.
*/
public String getVcsName() {
return vcsName;
}

/**
* @return the identifier for the remote repository. Usually, a URL.
*/
public String getRepositoryIdentifier() {
return repositoryIdentifier;
}
}

VcsUpdate


import com.eviware.soapui.impl.wsdl.WsdlProject;
import org.apache.commons.lang.StringUtils;

/**
* Represents an update of a file, either local or remote.
*/
public class VcsUpdate {

public enum VcsUpdateType {
/**
* The file has been added.
*/
ADDED,

/**
* The file has been deleted.
*/
DELETED,

/**
* The file has been modified.
*/
MODIFIED,

/**
* The file has been moved.
*/
MOVED
}

private WsdlProject project;
private final VcsUpdateType type;
private final String relativePath;
private final String oldRelativePath;
private boolean conflictingUpdate;

/**
* Creates new VcsUpdate.
*
* @param type - the type of the update.
* @param relativePath - the current path to the file relative to the project root. May be null if the file was deleted.
* @param oldRelativePath - the old path to the file relative to the project root.
* Used when a file has been moved or deleted, null otherwise.
*/
public VcsUpdate(WsdlProject project, VcsUpdateType type, String relativePath, String oldRelativePath) {
this.project = project;
this.type = type;
this.relativePath = relativePath;
this.oldRelativePath = oldRelativePath;
this.conflictingUpdate = false;
}

/**
*
* @return the project in which the update has been made.
*/
public WsdlProject getProject() {
return project;
}

/**
* @return the type of the update.
*/
public VcsUpdateType getType() {
return type;
}

/**
* @return the path to the file relative to the project root.
*/
public String getRelativePath() {
return relativePath;

}

/**
* @return the old path to this file relative to the project root. Only applicable if the file has been moved or deleted.
*/
public String getOldRelativePath() {
return oldRelativePath;
}

/**
* @return true if the changes in the file conflict with the remote counterpart, false otherwise.
*/
public boolean isConflictingUpdate() {
return conflictingUpdate;
}

public void setConflictingUpdate(boolean conflictingUpdate) {
this.conflictingUpdate = conflictingUpdate;
}

@Override
public boolean equals(Object o) {
if (o == null |<td></td>| getClass() != o.getClass()) {
return false;
}
VcsUpdate other = (VcsUpdate) o;
return type.equals(other.type) && StringUtils.equals(relativePath, other.relativePath) &&
StringUtils.equals(oldRelativePath, other.oldRelativePath) &&
conflictingUpdate == other.conflictingUpdate;
}

@Override
public int hashCode() {
int result = type != null " width=" type.hashCode() : 0;
result = 31 * result + (relativePath != null ? relativePath.hashCode() : 0);
result = 31 * result + (oldRelativePath != null ? oldRelativePath.hashCode() : 0);
result = 31 * result + (conflictingUpdate ? 1 : 0);
return result;
}
}

VcsLoadSaveSupport


package com.eviware.soapui.plugins.vcs;

/**
  * Checks if a project is being shared or committed.
* This affects the way the project saver acts.
*/
public class VcsLoadSaveSupport {
private static final ThreadLocal<Boolean> isCommitting = new ThreadLocal<>();
private static final ThreadLocal<Boolean> isSharing = new ThreadLocal<>();
private static final ThreadLocal<Boolean> isUpdating = new ThreadLocal<>();

public static void startCommit() {
isCommitting.set(Boolean.TRUE);
}

public static void stopCommit() {
isCommitting.remove();
}

public static boolean isCommitInProgress() {
return isCommitting.get() == Boolean.TRUE;
}

public static void startShareProject() {
isSharing.set(Boolean.TRUE);
}

public static void stopShareProject() {
isSharing.remove();
}

public static boolean isShareProjectInProgress() {
return isSharing.get() == Boolean.TRUE;
}

public static void startUpdateProject() {
isUpdating.set(Boolean.TRUE);
}

public static void stopUpdateProject() {
isUpdating.remove();
}

public static boolean isUpdateProjectInProgress() {
return isUpdating.get() == Boolean.TRUE;
}

}

VcsUserInteractions


import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.plugins.vcs.dialogs.RepositorySelectionDialog;
import com.eviware.soapui.support.UISupport;

/**
* A facade for all user interactions to be performed when VCS integration has been loaded.
*/
public class VcsUserInteractions {

private static Handler interactionsHandler = new DefaultHandler();

public static VcsRepositoryInfo getRepositoryInfoFromUser(WsdlProject project) {
return interactionsHandler.getRepositoryInfoFromUser(project);
}


/*
The accessor methods and the inner interface have been added to be able to mock out user interactions.
*/
static void setInteractionsHandler(Handler newInteractionsHandler) {
interactionsHandler = newInteractionsHandler;
}

static Handler getInteractionsHandler() {
return interactionsHandler;
}

public interface Handler {

VcsRepositoryInfo getRepositoryInfoFromUser(WsdlProject project);
}

private static class DefaultHandler implements Handler {

@Override
public VcsRepositoryInfo getRepositoryInfoFromUser(WsdlProject project) {

RepositorySelectionDialog repositorySelectionDialog = new RepositorySelectionDialog(project);
UISupport.showDialog(repositorySelectionDialog);

if(repositorySelectionDialog.isCancelled()){
return null;
}

return repositorySelectionDialog.getVcsRepositoryInfo();
}
}
}
Highlight search results