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

com.shaft.validation.internal.FileValidationsBuilder Maven / Gradle / Ivy

Go to download

SHAFT is a unified test automation engine. Powered by best-in-class frameworks, SHAFT provides a wizard-like syntax to drive your automation efficiently, maximize your ROI, and minimize your learning curve. Stop reinventing the wheel. Upgrade now!

There is a newer version: 8.2.20240402
Show newest version
package com.shaft.validation.internal;

import com.shaft.validation.ValidationEnums;

public class FileValidationsBuilder {
    protected final ValidationEnums.ValidationCategory validationCategory;
    protected String validationMethod;
    protected ValidationEnums.ValidationType validationType;
    protected final String folderRelativePath;
    protected final String fileName;

    protected final StringBuilder reportMessageBuilder;

    public FileValidationsBuilder(ValidationEnums.ValidationCategory validationCategory, String folderRelativePath, String fileName, StringBuilder reportMessageBuilder) {
        this.validationCategory = validationCategory;
        this.folderRelativePath = folderRelativePath;
        this.fileName = fileName;

        this.reportMessageBuilder = reportMessageBuilder;
    }

    /**
     * Use this to check if a certain file exists
     *
     * @return a ValidationsExecutor object to set your custom validation message (if needed) and then perform() your validation
     */
    public ValidationsExecutor exists() {
        this.validationMethod = "fileExists";
        this.validationType = ValidationEnums.ValidationType.POSITIVE;
        reportMessageBuilder.append("exists.");
        return new ValidationsExecutor(this);
    }

    /**
     * Use this to check if a certain file does not exist
     *
     * @return a ValidationsExecutor object to set your custom validation message (if needed) and then perform() your validation
     */
    public ValidationsExecutor doesNotExist() {
        this.validationMethod = "fileExists";
        this.validationType = ValidationEnums.ValidationType.NEGATIVE;
        reportMessageBuilder.append("does not exist.");
        return new ValidationsExecutor(this);
    }

    /**
     * Use this to calculate and check a certain file checksum to confirm if it has the exact same content or not
     *
     * @return a NativeValidationsBuilder object to continue building your validation
     */
    @SuppressWarnings("unused")
    public NativeValidationsBuilder checksum() {
        this.validationMethod = "fileChecksum";
        reportMessageBuilder.append("checksum ");
        return new NativeValidationsBuilder(this);
    }

    /**
     * Use this to attempt to read and validate a certain file content (works for PDF and TEXT files)
     *
     * @return a NativeValidationsBuilder object to continue building your validation
     */
    public NativeValidationsBuilder content() {
        this.validationMethod = "fileContent";
        reportMessageBuilder.append("content ");
        return new NativeValidationsBuilder(this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy