public boolean isSkip(ConditionalSimpleType execType, ConditionalComplexType... parentExecTypes) { if (parentExecTypes == null || parentExecTypes.length == 0) { return isSkip(execType); } return Arrays.asList(parentExecTypes).stream().anyMatch((execComplexType) -> isSkip(execComplexType)) || isSkip(execType); }
@Override public void execute() throws IOException { contextProvider.getDynamicContext() .addParameter(dynamicParameter, ContextInfo.EMPTY, skipOperationResolver.isSkip(dynamicParameter)); }
public boolean isSkip(ConditionalSimpleType execType) { return isSkip(execType.getIf(), execType.getUnless()); }
public boolean isSkip(ConditionalComplexType execType) { return isSkip(execType.getIf(), execType.getUnless()); }
private List<OperationInfo> getSubPipeOperations(SubPipeType subPipe) { return subPipe.getExecOnce().stream() .map(execOnce -> new OperationInfo(execOnce.getValue(), execOnce.getName(), ContextInfo.EMPTY, skipOperationResolver .setContextInfo(ContextInfo.EMPTY) .isSkip(execOnce))) .collect(Collectors.toList()); }
private List<OperationInfo> getSubPipeOperations(SubPipeType subPipe) { ContextInfo contextInfo = new ContextInfoBuilder() .setSegmentUuid(currentSegmentUuid) .build(); return subPipe.getExecOnce().stream() .map(execOnce -> new OperationInfo(execOnce.getValue(), execOnce.getName(), contextInfo, skipOperationResolver .setContextInfo(contextInfo) .isSkip(execOnce, execEachSegm))) .collect(Collectors.toList()); }
private OperationInfo getExecOnceOperation(ExecOnceType execOnce) { return new OperationInfo(execOnce.getValue(), execOnce.getName(), ContextInfo.EMPTY, skipOperationResolver .setContextInfo(ContextInfo.EMPTY) .isSkip(execOnce)); }
@Override public void execute() throws IOException { OperationInfo operationInfo = new OperationInfo(operation.getValue(), operation.getName(), ContextInfo.EMPTY, skipOperationResolver .setContextInfo(ContextInfo.EMPTY) .isSkip(operation)); executeStrategyFactory.createExecuteOnceStrategy(contextProvider).execute(operationInfo); }
private void addDynamicParameter(DynamicParameterConcatType dynamicParam) { ContextInfo contextInfo = new ContextInfoBuilder() .setSegmentUuid(currentSegmentUuid) .build(); contextProvider.getDynamicContext().addParameter(dynamicParam, contextInfo, skipOperationResolver .setContextInfo(contextInfo) .isSkip(dynamicParam, execEachSegm)); }
private void addDynamicParameter(DynamicParameterConcatType dynamicParam) { ContextInfo contextInfo = new ContextInfoBuilder() .setSequenceUuid(currentSeqUuid) .setSequenceType(seqType) .build(); contextProvider.getDynamicContext().addParameter(dynamicParam, contextInfo, skipOperationResolver .setContextInfo(contextInfo) .isSkip(dynamicParam, execEachSeq)); }
private OperationInfo getExecOnceOperation(ExecOnceType execOnce) { ContextInfo contextInfo = new ContextInfoBuilder() .setSegmentUuid(currentSegmentUuid) .build(); return new OperationInfo(execOnce.getValue(), execOnce.getName(), contextInfo, skipOperationResolver .setContextInfo(contextInfo) .isSkip(execOnce, execEachSegm)); }
private OperationInfo getExecOnceOperation(ExecOnceType execOnce) { ContextInfo contextInfo = new ContextInfoBuilder() .setSequenceUuid(currentSeqUuid) .setSequenceType(seqType) .build(); return new OperationInfo(execOnce.getValue(), execOnce.getName(), contextInfo, skipOperationResolver .setContextInfo(contextInfo) .isSkip(execOnce, execEachSeq)); }
/** * Resolves dynamic parameter name and value and add to dynamic context. * * @param dynParam dynamic parameter to add */ private void addDynamicParameter(DynamicParameterConcatType dynParam, Map<String, Integer> iterators) { DynamicParameterConcatType resolvedParameter = contextProvider.getDynamicContext().cloneParameter(dynParam); resolvedParameter.setName(parameterResolver.resolveIteratorParameter(resolvedParameter.getName(), iterators)); resolvedParameter.setValue(parameterResolver.resolveIteratorParameter(resolvedParameter.getValue(), iterators)); resolvedParameter.setAdd(parameterResolver.resolveIteratorParameter(resolvedParameter.getAdd(), iterators)); contextProvider.getDynamicContext().addParameter(resolvedParameter, ContextInfo.EMPTY, skipOperationResolver.isSkip(dynParam)); }
@Test(expected = TemplateParameterNotFoundException.class) public void testInvalidContextParameter() { SkipOperationResolver resolver = new SkipOperationResolver(new TemplateParameterResolver(contextProvider)); ExecOnceType exec = new ExecOnceType(); exec.setIf("%{dynamic.null}"); resolver.setContextInfo(ContextInfo.EMPTY).isSkip(exec); }
@Test(expected = UnknownTemplateParameterContextException.class) public void testInvalidContext() { SkipOperationResolver resolver = new SkipOperationResolver(new TemplateParameterResolver(contextProvider)); ExecOnceType exec = new ExecOnceType(); exec.setIf("%{null.true}"); resolver.setContextInfo(ContextInfo.EMPTY).isSkip(exec); }
@Test public void testDamagedContextParameter() { SkipOperationResolver resolver = new SkipOperationResolver(new TemplateParameterResolver(contextProvider)); ExecOnceType exec = new ExecOnceType(); exec.setIf("%{dynamic.damagedParam}"); // convert to false in result assertTrue(resolver.setContextInfo(ContextInfo.EMPTY).isSkip(exec)); }
@Test public void testEmptyParameter() { SkipOperationResolver resolver = new SkipOperationResolver(new TemplateParameterResolver(contextProvider)); ExecOnceType exec = new ExecOnceType(); exec.setIf(""); // convert to false in result assertTrue(resolver.setContextInfo(ContextInfo.EMPTY).isSkip(exec)); }
@Test public void testInvalidBoolean() { SkipOperationResolver resolver = new SkipOperationResolver(new TemplateParameterResolver(contextProvider)); ExecOnceType ifInvalidExec = new ExecOnceType(); ifInvalidExec.setIf("true"); ifInvalidExec.setUnless("123"); // convert to false in result assertFalse(resolver.setContextInfo(ContextInfo.EMPTY).isSkip(ifInvalidExec)); }
@Test public void testFewOperationsSkipped() { SkipOperationResolver resolver = new SkipOperationResolver(new TemplateParameterResolver(contextProvider)); ConditionalSimpleType trueExec1 = new ExecOnceType(); trueExec1.setUnless("false"); ConditionalComplexType trueExec2 = new ConditionalComplexType(); trueExec2.setIf("true"); ConditionalComplexType falseExec = new ConditionalComplexType(); falseExec.setIf("false"); assertTrue(resolver.setContextInfo(ContextInfo.EMPTY).isSkip(trueExec1, trueExec2, falseExec)); }
@Test public void testContextInfo() { SkipOperationResolver resolver = new SkipOperationResolver(new TemplateParameterResolver(contextProvider)); ExecOnceType exec = new ExecOnceType(); exec.setIf("true"); assertFalse(resolver .setContextInfo(new ContextInfoBuilder() .setSequenceUuid(SequenceUUID.create("seq:urn")) .setResourceUuid(ResourceUUID.create("res:urn", 0)) .build()) .isSkip(exec)); } }