use of com.sequenceiq.it.cloudbreak.context.TestCaseDescription in project cloudbreak by hortonworks.
the class MultiThreadTenantTest method collectTestCaseDescription.
private TestCaseDescription collectTestCaseDescription(MockedTestContext testContext, Method method, Object[] params) {
Description declaredAnnotation = method.getDeclaredAnnotation(Description.class);
TestCaseDescription testCaseDescription = null;
if (declaredAnnotation != null) {
testCaseDescription = new TestCaseDescriptionBuilder().given(declaredAnnotation.given()).when(declaredAnnotation.when()).then(declaredAnnotation.then());
testContext.addDescription(testCaseDescription);
} else if (method.getParameters().length == params.length) {
Parameter[] parameters = method.getParameters();
for (int i = 1; i < parameters.length; i++) {
if (parameters[i].getAnnotation(Description.class) != null) {
Object param = params[i];
if (!(param instanceof TestCaseDescription)) {
throw new IllegalArgumentException("The param annotated with @Description but the type is should be " + TestCaseDescription.class.getSimpleName());
}
testCaseDescription = (TestCaseDescription) param;
testContext.addDescription(testCaseDescription);
break;
}
}
}
return Optional.ofNullable(testCaseDescription).filter(d -> !Strings.isNullOrEmpty(d.getValue())).orElseThrow(() -> new TestCaseDescriptionMissingException(method.getName()));
}
use of com.sequenceiq.it.cloudbreak.context.TestCaseDescription in project cloudbreak by hortonworks.
the class AbstractMinimalTest method collectTestCaseDescription.
private TestCaseDescription collectTestCaseDescription(TestContext testContext, Method method, Object[] params) {
Description declaredAnnotation = method.getDeclaredAnnotation(Description.class);
TestCaseDescription testCaseDescription = null;
if (declaredAnnotation != null) {
testCaseDescription = new TestCaseDescriptionBuilder().given(declaredAnnotation.given()).when(declaredAnnotation.when()).then(declaredAnnotation.then());
testContext.addDescription(testCaseDescription);
} else if (method.getParameters().length == params.length) {
Parameter[] parameters = method.getParameters();
for (int i = 1; i < parameters.length; i++) {
if (parameters[i].getAnnotation(Description.class) != null) {
Object param = params[i];
if (!(param instanceof TestCaseDescription)) {
throw new IllegalArgumentException("The param annotated with @Description but the type is should be " + TestCaseDescription.class.getSimpleName());
}
testCaseDescription = (TestCaseDescription) param;
testContext.addDescription(testCaseDescription);
break;
}
}
}
return Optional.ofNullable(testCaseDescription).filter(d -> !Strings.isNullOrEmpty(d.getValue())).orElseThrow(() -> new TestCaseDescriptionMissingException(method.getName()));
}
Aggregations