@Test public void evalInvalidFileTest() { RegexMatch regexMatch; TUExecutionResult executionResult; regexMatch = new RegexMatch("*Mustache*").relative("/src/main/resources/caes.yaml"); executionResult = regexMatch.execution(transformedAppFolder, transformationContext); Assert.assertEquals(executionResult.getType(), TUExecutionResult.Type.ERROR); Assert.assertNull(executionResult.getValue()); Assert.assertEquals(executionResult.getException().getClass(), FileNotFoundException.class); Assert.assertEquals(executionResult.getException().getMessage(), "File to be evaluated has not been found"); }
@Override protected TUExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File file = getAbsoluteFile(transformedAppFolder, transformationContext); if (!file.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be evaluated has not been found"); return TUExecutionResult.error(this, ex); } BufferedReader reader = null; boolean evalResult = false; TUExecutionResult result = null; try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); evalResult = evaluate(reader); result = TUExecutionResult.value(this, evalResult); } catch (Exception e) { result = TUExecutionResult.error(this, e); } finally { if(reader != null) try { reader.close(); } catch (IOException e) { if (result != null) { result.addWarning(e); } } } return result; }
RegexMatch extends SingleCondition<RegexMatch> { @Override protected TUExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File file = getAbsoluteFile(transformedAppFolder, transformationContext); if (!file.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be evaluated has not been found"); return TUExecutionResult.error(this, ex); } BufferedReader reader = null; boolean evalResult = false; TUExecutionResult result = null; try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); evalResult = evaluate(reader); result = TUExecutionResult.value(this, evalResult); } catch (Exception e) { result = TUExecutionResult.error(this, e); } finally { if(reader != null) try { reader.close(); } catch (IOException e) { if (result != null) { result.addWarning(e); } } } return result; } }
RegexMatch extends SingleCondition<RegexMatch> { @Override protected TUExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File file = getAbsoluteFile(transformedAppFolder, transformationContext); if (!file.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be evaluated has not been found"); return TUExecutionResult.error(this, ex); } BufferedReader reader = null; boolean evalResult = false; TUExecutionResult result = null; try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); evalResult = evaluate(reader); result = TUExecutionResult.value(this, evalResult); } catch (Exception e) { result = TUExecutionResult.error(this, e); } finally { if(reader != null) try { reader.close(); } catch (IOException e) { if (result != null) { result.addWarning(e); } } } return result; } RegexMatch();  RegexMatch(String regex); }
RegexMatch extends SingleCondition<RegexMatch> { @Override protected TUExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File file = getAbsoluteFile(transformedAppFolder, transformationContext); if (!file.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be evaluated has not been found"); return TUExecutionResult.error(this, ex); } BufferedReader reader = null; boolean evalResult = false; TUExecutionResult result = null; try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); evalResult = evaluate(reader); result = TUExecutionResult.value(this, evalResult); } catch (Exception e) { result = TUExecutionResult.error(this, e); } finally { if(reader != null) try { reader.close(); } catch (IOException e) { if (result != null) { result.addWarning(e); } } } return result; } RegexMatch();  RegexMatch(String regex); RegexMatch setRegex(String regex); String getRegex(); @Override String getDescription(); }
RegexMatch extends SingleCondition<RegexMatch> { @Override protected TUExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) { File file = getAbsoluteFile(transformedAppFolder, transformationContext); if (!file.exists()) { FileNotFoundException ex = new FileNotFoundException("File to be evaluated has not been found"); return TUExecutionResult.error(this, ex); } BufferedReader reader = null; boolean evalResult = false; TUExecutionResult result = null; try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)); evalResult = evaluate(reader); result = TUExecutionResult.value(this, evalResult); } catch (Exception e) { result = TUExecutionResult.error(this, e); } finally { if(reader != null) try { reader.close(); } catch (IOException e) { if (result != null) { result.addWarning(e); } } } return result; } RegexMatch();  RegexMatch(String regex); RegexMatch setRegex(String regex); String getRegex(); @Override String getDescription();  }