TransformationUtility implements Cloneable { public final T executeIf(String conditionAttributeName) { if(StringUtils.isBlank(conditionAttributeName)) { throw new TransformationDefinitionException("Condition attribute name cannot be blank"); } this.ifConditionAttributeName = conditionAttributeName; return (T) this; } @SuppressWarnings("PMD.UnnecessaryConstructor")  TransformationUtility(); final String getName(); T setContextAttributeName(String contextAttributeName); String getContextAttributeName(); final T setParent(TransformationUtilityParent parent, int order); TransformationUtilityParent getParent(); TransformationTemplate getTransformationTemplate(); abstract String getDescription(); int getOrder(); final T relative(String relativePath); final T set(String propertyName, String contextAttributeName); T absolute(String contextAttributeName); T absolute(String contextAttributeName, String additionalRelativePath); @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") PerformResult perform(File transformedAppFolder, TransformationContext transformationContext); final T abortOnFailure(boolean abort); final T abortOnFailure(String abortionMessage); String getAbortionMessage(); final boolean isAbortOnFailure(); boolean isSaveResult(); final boolean hasBeenPerformed(); final T dependsOn(String... dependencies); final T executeIf(String conditionAttributeName); final T executeIf(UtilityCondition utilityCondition); final T executeUnless(String conditionAttributeName); String getIfConditionAttributeName(); String getUnlessConditionAttributeName(); final boolean isFileSet(); final boolean wasFileExplicitlySet(); @Override String toString(); @Override T clone(); T copy(); @Override @SuppressWarnings("PMD.SimplifyBooleanReturns") boolean equals(Object obj); @Override int hashCode();  }
@Test public void executeIf() { Mockito.when(transformationContext.contains("ATT")).thenReturn(true); Mockito.when(transformationContext.get("ATT")).thenReturn(true); TransformationUtility transformationUtility = getNewTestTransformationUtility().executeIf("ATT"); assertFalse(transformationUtility.hasBeenPerformed()); PerformResult performResult = transformationUtility.perform(transformedAppFolder, transformationContext); assertTrue(transformationUtility.hasBeenPerformed()); assertEquals(performResult.getType(), PerformResult.Type.EXECUTION_RESULT); assertEquals(performResult.getExecutionResult().getType(), TUExecutionResult.Type.VALUE); assertEquals(((TUExecutionResult) performResult.getExecutionResult()).getValue(), transformedAppFolder); }
@Test(expectedExceptions = TransformationDefinitionException.class, expectedExceptionsMessageRegExp = "Condition attribute name cannot be blank") public void executeIfBlankContextAttributeTest() { getNewTestTransformationUtility().executeIf(""); }
@Test(expectedExceptions = TransformationDefinitionException.class, expectedExceptionsMessageRegExp = "Utility condition object cannot be null") public void executeIfObjectNullContextAttributeTest() { getNewTestTransformationUtility().executeIf((UtilityCondition) null); }