@Test public void invalidParamType() { EvaluationFunction evFunction = engine.buildEvaluationFunction(FUNCTION_NAME) .withValueParam(PARAM_NAME, ValueType.FILE, new ValueEvaluation(PSP_DIR_FILEID)); ValueEvaluation evaluation = evFunction.evaluate(); assertNull(evaluation.getData()); assertNotNull(evaluation.getErrorMessage()); }
@Override public ValueEvaluation evaluate() { try { checkContractCompliance(); ValueEvaluation paramFileId = valueParams.getParams(PARAM_FILE_ID).get(0).getEvaluation(); String fileId = (String) paramFileId.getData(); if (fileId == null) { return errorResultParamNull(PARAM_FILE_ID, paramFileId); } else if (fileId.isEmpty()) { return errorResult(String.format("hodnota parametru %s je prázdná", PARAM_FILE_ID)); } File file = engine.getProvidedVarsManager().getProvidedFile(fileId); if (file == null) { return errorResult(String.format("soubor s id %s není poskytován", fileId)); } else { return okResult(file); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } }
EfGetProvidedFile extends EvaluationFunction { @Override public ValueEvaluation evaluate() { try { checkContractCompliance(); ValueEvaluation paramFileId = valueParams.getParams(PARAM_FILE_ID).get(0).getEvaluation(); String fileId = (String) paramFileId.getData(); if (fileId == null) { return errorResultParamNull(PARAM_FILE_ID, paramFileId); } else if (fileId.isEmpty()) { return errorResult(String.format("hodnota parametru %s je prázdná", PARAM_FILE_ID)); } File file = engine.getProvidedVarsManager().getProvidedFile(fileId); if (file == null) { return errorResult(String.format("soubor s id %s není poskytován", fileId)); } else { return okResult(file); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } } }
EfGetProvidedFile extends EvaluationFunction { @Override public ValueEvaluation evaluate() { try { checkContractCompliance(); ValueEvaluation paramFileId = valueParams.getParams(PARAM_FILE_ID).get(0).getEvaluation(); String fileId = (String) paramFileId.getData(); if (fileId == null) { return errorResultParamNull(PARAM_FILE_ID, paramFileId); } else if (fileId.isEmpty()) { return errorResult(String.format("hodnota parametru %s je prázdná", PARAM_FILE_ID)); } File file = engine.getProvidedVarsManager().getProvidedFile(fileId); if (file == null) { return errorResult(String.format("soubor s id %s není poskytován", fileId)); } else { return okResult(file); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } } EfGetProvidedFile(String name, Engine engine); }
EfGetProvidedFile extends EvaluationFunction { @Override public ValueEvaluation evaluate() { try { checkContractCompliance(); ValueEvaluation paramFileId = valueParams.getParams(PARAM_FILE_ID).get(0).getEvaluation(); String fileId = (String) paramFileId.getData(); if (fileId == null) { return errorResultParamNull(PARAM_FILE_ID, paramFileId); } else if (fileId.isEmpty()) { return errorResult(String.format("hodnota parametru %s je prázdná", PARAM_FILE_ID)); } File file = engine.getProvidedVarsManager().getProvidedFile(fileId); if (file == null) { return errorResult(String.format("soubor s id %s není poskytován", fileId)); } else { return okResult(file); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } } EfGetProvidedFile(String name, Engine engine); @Override ValueEvaluation evaluate(); }
EfGetProvidedFile extends EvaluationFunction { @Override public ValueEvaluation evaluate() { try { checkContractCompliance(); ValueEvaluation paramFileId = valueParams.getParams(PARAM_FILE_ID).get(0).getEvaluation(); String fileId = (String) paramFileId.getData(); if (fileId == null) { return errorResultParamNull(PARAM_FILE_ID, paramFileId); } else if (fileId.isEmpty()) { return errorResult(String.format("hodnota parametru %s je prázdná", PARAM_FILE_ID)); } File file = engine.getProvidedVarsManager().getProvidedFile(fileId); if (file == null) { return errorResult(String.format("soubor s id %s není poskytován", fileId)); } else { return okResult(file); } } catch (ContractException e) { return errorResultContractNotMet(e); } catch (Throwable e) { return errorResultUnexpectedError(e); } } EfGetProvidedFile(String name, Engine engine); @Override ValueEvaluation evaluate();  }