com.vocalabs.egtest.processor.junit.MatchWriter Maven / Gradle / Ivy
package com.vocalabs.egtest.processor.junit;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.TypeSpec;
import com.vocalabs.egtest.annotation.EgMatch;
import com.vocalabs.egtest.annotation.EgNoMatch;
import com.vocalabs.egtest.processor.data.Example;
import javax.lang.model.element.Element;
import java.lang.annotation.Annotation;
import java.util.List;
abstract class MatchWriter> extends JUnitExampleWriter {
public MatchWriter(T element, List examples, JUnitClassWriter classWriter, TypeSpec.Builder toAddTo) {
super(element, examples, classWriter, toAddTo);
}
@Override
protected String baseName() {
return "Match";
}
protected ClassName booleanAssertion(Annotation annotation) {
final String boolStr;
if (annotation instanceof EgMatch)
boolStr = "True";
else if (annotation instanceof EgNoMatch)
boolStr = "False";
else throw new IllegalArgumentException(this + " doesn't handle " + annotation);
return ClassName.get("org.junit.Assert", "assert" + boolStr);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy