com.undefinedlabs.scope.rules.model.JUnit4ScopeDescription Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scope-rule-junit4 Show documentation
Show all versions of scope-rule-junit4 Show documentation
Scope is a APM for tests to give engineering teams unprecedented visibility into their CI process to quickly identify, troubleshoot and fix failed builds.
This artifact contains the classes to instrument the JUnit4 tests.
package com.undefinedlabs.scope.rules.model;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.junit.runner.Description;
public class JUnit4ScopeDescription {
private final String className;
private final String methodName;
private final String methodNameNoSpecialChars;
public JUnit4ScopeDescription(final Description description) {
this.className = StringUtils.isNotEmpty(description.getClassName()) ? description.getClassName() : "";
this.methodName = StringUtils.isNotEmpty(description.getMethodName()) ? description.getMethodName(): "";
this.methodNameNoSpecialChars = removeIteration(this.methodName);
}
private String removeIteration(String methodName) {
if(!methodName.contains("[")){
return methodName;
}
final String iteration = methodName.substring(methodName.indexOf("["), methodName.indexOf("]") + 1);
return methodName.replace(iteration, "");
}
public String getClassName() {
return className;
}
public String getMethodName() {
return methodName;
}
public String getMethodNameNoSpecialChars() {
return methodNameNoSpecialChars;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JUnit4ScopeDescription that = (JUnit4ScopeDescription) o;
return new EqualsBuilder()
.append(className, that.className)
.append(methodName, that.methodName)
.append(methodNameNoSpecialChars, that.methodNameNoSpecialChars)
.isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(className)
.append(methodName)
.append(methodNameNoSpecialChars)
.toHashCode();
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("className", className)
.append("methodName", methodName)
.append("methodNameNoSpecialChars", methodNameNoSpecialChars)
.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy