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

com.github.siwenyan.si.SiContextMonitorEvent Maven / Gradle / Ivy

There is a newer version: 1.25.1.0
Show newest version
package com.github.siwenyan.si;

public class SiContextMonitorEvent {

    public static enum Type {
        BEFORE_COMMAND, AFTER_COMMAND, BEFORE_TEST, AFTER_TEST
    }

    private final SiCommand siCommand;
    private final SiTest siTest;
    private final Type type;

    public SiContextMonitorEvent(SiCommand siCommand, SiTest siTest, Type type) {
        this.siCommand = siCommand;
        this.siTest = siTest;
        this.type = type;
    }

    public SiTest getSiTest() {
        return this.siTest;
    }

    public Type getType() {
        return this.type;
    }

    public String getName() {
        String eventName = null;

        switch (this.getType()) {
            case BEFORE_COMMAND:
                eventName = "before ";
                eventName += this.siTest.getSiModelTest().getName();
                eventName += "::" + this.siCommand.getSiModelCommand().getCommand();
                eventName += "::" + this.siCommand.getSiModelCommand().getTarget();
                break;
            case AFTER_COMMAND:
                eventName = "after ";
                eventName += this.siTest.getSiModelTest().getName();
                eventName += "::" + this.siCommand.getSiModelCommand().getCommand();
                eventName += "::" + this.siCommand.getSiModelCommand().getTarget();
                break;
            case BEFORE_TEST:
                eventName = "before ";
                eventName += this.siTest.getSiModelTest().getName();
                break;
            case AFTER_TEST:
                eventName = "after ";
                eventName += this.siTest.getSiModelTest().getName();
                break;
            default:
                //do nothing
        }

        return eventName;
    }

    @Override
    public String toString() {
        String s = this.getType().toString();
        if (null != this.siCommand) {
            s += "::" + this.siCommand.toString();
        }
        s += "::" + this.siTest.toString();
        return s;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy