com.klarna.hiverunner.annotations.HiveSetupScript Java Examples

The following examples show how to use com.klarna.hiverunner.annotations.HiveSetupScript. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlinkStandaloneHiveRunner.java    From flink with Apache License 2.0 6 votes vote down vote up
private void loadAnnotatedSetupScripts(Class testClass, HiveShellBuilder hiveShellBuilder) {
	Set<Field> setupScriptFields = ReflectionUtils.getAllFields(testClass, withAnnotation(HiveSetupScript.class));
	for (Field setupScriptField : setupScriptFields) {
		if (ReflectionUtils.isOfType(setupScriptField, String.class)) {
			String script = ReflectionUtils.getStaticFieldValue(testClass, setupScriptField.getName(), String.class);
			hiveShellBuilder.addSetupScript(script);
		} else if (ReflectionUtils.isOfType(setupScriptField, File.class) ||
				ReflectionUtils.isOfType(setupScriptField, Path.class)) {
			Path path = getMandatoryPathFromField(testClass, setupScriptField);
			hiveShellBuilder.addSetupScript(readAll(path));
		} else {
			throw new IllegalArgumentException(
					"Field annotated with @HiveSetupScript currently only supports type String, File and Path");
		}
	}
}
 
Example #2
Source File: FlinkStandaloneHiveRunner.java    From flink with Apache License 2.0 6 votes vote down vote up
private void loadAnnotatedSetupScripts(Class testClass, HiveShellBuilder hiveShellBuilder) {
	Set<Field> setupScriptFields = ReflectionUtils.getAllFields(testClass, withAnnotation(HiveSetupScript.class));
	for (Field setupScriptField : setupScriptFields) {
		if (ReflectionUtils.isOfType(setupScriptField, String.class)) {
			String script = ReflectionUtils.getStaticFieldValue(testClass, setupScriptField.getName(), String.class);
			hiveShellBuilder.addSetupScript(script);
		} else if (ReflectionUtils.isOfType(setupScriptField, File.class) ||
				ReflectionUtils.isOfType(setupScriptField, Path.class)) {
			Path path = getMandatoryPathFromField(testClass, setupScriptField);
			hiveShellBuilder.addSetupScript(readAll(path));
		} else {
			throw new IllegalArgumentException(
					"Field annotated with @HiveSetupScript currently only supports type String, File and Path");
		}
	}
}
 
Example #3
Source File: HiveRunnerCore.java    From HiveRunner with Apache License 2.0 6 votes vote down vote up
private void loadAnnotatedSetupScripts(Object testCase, HiveShellBuilder workFlowBuilder) {
  Set<Field> setupScriptFields = ReflectionUtils.getAllFields(testCase.getClass(),
      withAnnotation(HiveSetupScript.class));

  for (Field setupScriptField : setupScriptFields) {
    if (ReflectionUtils.isOfType(setupScriptField, String.class)) {
      String script = ReflectionUtils.getFieldValue(testCase, setupScriptField.getName(), String.class);
      workFlowBuilder.addSetupScript(script);
    } else if (ReflectionUtils.isOfType(setupScriptField, File.class) ||
        ReflectionUtils.isOfType(setupScriptField, Path.class)) {
      Path path = getMandatoryPathFromField(testCase, setupScriptField);
      workFlowBuilder.addSetupScript(readAll(path));
    } else {
      throw new IllegalArgumentException(
          "Field annotated with @HiveSetupScript currently only supports type String, File and Path");
    }
  }
}