How to use path method of com.consol.citrus.dsl.builder.WaitFileConditionBuilder class

Best Citrus code snippet using com.consol.citrus.dsl.builder.WaitFileConditionBuilder.path

Source:DefaultTestRunner.java Github

copy

Full Screen

1/*2 * Copyright 2006-2015 the original author or authors.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package com.consol.citrus.dsl.runner;17import java.io.File;18import java.util.Date;19import java.util.Stack;20import com.consol.citrus.AbstractTestContainerBuilder;21import com.consol.citrus.DefaultTestCase;22import com.consol.citrus.TestAction;23import com.consol.citrus.TestActionBuilder;24import com.consol.citrus.TestActionContainerBuilder;25import com.consol.citrus.TestCase;26import com.consol.citrus.TestCaseMetaInfo;27import com.consol.citrus.actions.AntRunAction;28import com.consol.citrus.actions.CreateVariablesAction;29import com.consol.citrus.actions.EchoAction;30import com.consol.citrus.actions.ExecutePLSQLAction;31import com.consol.citrus.actions.ExecuteSQLAction;32import com.consol.citrus.actions.ExecuteSQLQueryAction;33import com.consol.citrus.actions.FailAction;34import com.consol.citrus.actions.InputAction;35import com.consol.citrus.actions.LoadPropertiesAction;36import com.consol.citrus.actions.PurgeEndpointAction;37import com.consol.citrus.actions.ReceiveMessageAction;38import com.consol.citrus.actions.ReceiveTimeoutAction;39import com.consol.citrus.actions.SendMessageAction;40import com.consol.citrus.actions.SleepAction;41import com.consol.citrus.actions.StartServerAction;42import com.consol.citrus.actions.StopServerAction;43import com.consol.citrus.actions.StopTimeAction;44import com.consol.citrus.actions.StopTimerAction;45import com.consol.citrus.actions.TraceVariablesAction;46import com.consol.citrus.actions.TransformAction;47import com.consol.citrus.condition.ActionCondition;48import com.consol.citrus.condition.Condition;49import com.consol.citrus.condition.FileCondition;50import com.consol.citrus.condition.HttpCondition;51import com.consol.citrus.container.Assert;52import com.consol.citrus.container.Async;53import com.consol.citrus.container.Catch;54import com.consol.citrus.container.Conditional;55import com.consol.citrus.container.FinallySequence;56import com.consol.citrus.container.Iterate;57import com.consol.citrus.container.Parallel;58import com.consol.citrus.container.RepeatOnErrorUntilTrue;59import com.consol.citrus.container.RepeatUntilTrue;60import com.consol.citrus.container.Sequence;61import com.consol.citrus.container.Template;62import com.consol.citrus.container.TestActionContainer;63import com.consol.citrus.container.Timer;64import com.consol.citrus.container.Wait;65import com.consol.citrus.container.WaitActionConditionBuilder;66import com.consol.citrus.container.WaitFileConditionBuilder;67import com.consol.citrus.container.WaitHttpConditionBuilder;68import com.consol.citrus.context.TestContext;69import com.consol.citrus.dsl.builder.AssertSoapFaultBuilder;70import com.consol.citrus.dsl.builder.BuilderSupport;71import com.consol.citrus.dsl.builder.CamelRouteActionBuilder;72import com.consol.citrus.dsl.builder.DockerExecuteActionBuilder;73import com.consol.citrus.dsl.builder.HttpActionBuilder;74import com.consol.citrus.dsl.builder.KubernetesExecuteActionBuilder;75import com.consol.citrus.dsl.builder.PurgeJmsQueuesActionBuilder;76import com.consol.citrus.dsl.builder.PurgeMessageChannelActionBuilder;77import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;78import com.consol.citrus.dsl.builder.SeleniumActionBuilder;79import com.consol.citrus.dsl.builder.SendMessageActionBuilder;80import com.consol.citrus.dsl.builder.SoapActionBuilder;81import com.consol.citrus.dsl.builder.ZooExecuteActionBuilder;82import com.consol.citrus.exceptions.CitrusRuntimeException;83import com.consol.citrus.script.GroovyAction;84import com.consol.citrus.server.Server;85/**86 * Default test runner implementation. Provides Java DSL methods for test actions. Immediately executes test actions as87 * they were built. This way the test case grows with each test action and changes for instance to the test context (variables) are88 * immediately visible.89 *90 * @author Christoph Deppisch91 * @since 2.392 */93public class DefaultTestRunner implements TestRunner {94 /** Test case */95 private final DefaultTestCase testCase;96 /** This runners test context */97 private TestContext context;98 /** Optional stack of containers cached for execution */99 protected Stack<TestActionContainerBuilder<? extends TestActionContainer, ?>> containers = new Stack<>();100 /** Default constructor */101 public DefaultTestRunner() {102 testCase = new DefaultTestCase();103 testClass(this.getClass());104 name(this.getClass().getSimpleName());105 packageName(this.getClass().getPackage().getName());106 }107 /**108 * Constructor initializing test case.109 * @param testCase110 */111 protected DefaultTestRunner(DefaultTestCase testCase) {112 this.testCase = testCase;113 }114 /**115 * Constructor using Spring bean application context.116 * @param context117 */118 public DefaultTestRunner(TestContext context) {119 this();120 this.context = context;121 }122 @Override123 public void testClass(Class<?> type) {124 testCase.setTestClass(type);125 }126 @Override127 public void name(String name) {128 testCase.setName(name);129 }130 @Override131 public void description(String description) {132 testCase.setDescription(description);133 }134 @Override135 public void author(String author) {136 testCase.getMetaInfo().setAuthor(author);137 }138 @Override139 public void packageName(String packageName) {140 testCase.setPackageName(packageName);141 }142 @Override143 public void status(TestCaseMetaInfo.Status status) {144 testCase.getMetaInfo().setStatus(status);145 }146 @Override147 public void creationDate(Date date) {148 testCase.getMetaInfo().setCreationDate(date);149 }150 @Override151 public void groups(String[] groups) {152 this.testCase.setGroups(groups);153 }154 @Override155 public void start() {156 testCase.start(context);157 }158 @Override159 public void stop() {160 testCase.finish(context);161 }162 @Override163 public <T> T variable(String name, T value) {164 testCase.getVariableDefinitions().put(name, value);165 if (value instanceof String) {166 String resolved = context.replaceDynamicContentInString(value.toString());167 context.setVariable(name, resolved);168 return (T) resolved;169 } else {170 context.setVariable(name, value);171 return value;172 }173 }174 @Override175 public <A extends TestAction> TestActionBuilder<A> run(A testAction) {176 return run((TestActionBuilder<A>)() -> testAction);177 }178 @Override179 public <T extends TestActionBuilder<?>> T run(T builder) {180 if (builder instanceof TestActionContainerBuilder<?, ?>) {181 if (containers.lastElement().equals(builder)) {182 containers.pop();183 } else {184 throw new CitrusRuntimeException("Invalid use of action containers - the container execution is not expected!");185 }186 if (builder instanceof FinallySequence.Builder) {187 ((FinallySequence.Builder) builder).getActions().forEach(testCase::addFinalAction);188 return builder;189 }190 }191 if (containers.isEmpty()) {192 testCase.addTestAction(builder);193 testCase.executeAction(builder.build(), context);194 } else {195 containers.lastElement().getActions().add(builder);196 }197 return builder;198 }199 @Override200 public ApplyTestBehaviorAction.Builder applyBehavior(TestBehavior behavior) {201 ApplyTestBehaviorAction.Builder builder = new ApplyTestBehaviorAction.Builder()202 .runner(this)203 .behavior(behavior);204 behavior.setTestContext(context);205 builder.build().execute(context);206 return builder;207 }208 @Override209 public <T extends TestActionContainer, B extends TestActionContainerBuilder<T, B>> TestActionContainerBuilder<T, B> container(T container) {210 TestActionContainerBuilder<T, B> builder = new AbstractTestContainerBuilder<T, B>() {211 @Override212 public B actions(TestActionBuilder<?>... actions) {213 return run(super.actions(actions));214 }215 @Override216 protected T doBuild() {217 return container;218 }219 @Override220 public T build() {221 if (container.getActions().size() > 0) {222 return container;223 }224 return super.build();225 }226 };227 return container(builder);228 }229 @Override230 public <T extends TestActionContainerBuilder<? extends TestActionContainer, ?>> T container(T container) {231 containers.push(container);232 return container;233 }234 @Override235 public CreateVariablesAction.Builder createVariable(String variableName, String value) {236 CreateVariablesAction.Builder builder = CreateVariablesAction.Builder.createVariable(variableName, value);237 return run(builder);238 }239 @Override240 public AntRunAction.Builder antrun(BuilderSupport<AntRunAction.Builder> configurer) {241 AntRunAction.Builder builder = new AntRunAction.Builder();242 configurer.configure(builder);243 return run(builder);244 }245 @Override246 public EchoAction.Builder echo(String message) {247 return run(new EchoAction.Builder().message(message));248 }249 @Override250 public ExecutePLSQLAction.Builder plsql(BuilderSupport<ExecutePLSQLAction.Builder> configurer) {251 ExecutePLSQLAction.Builder builder = new ExecutePLSQLAction.Builder();252 configurer.configure(builder);253 return run(builder);254 }255 @Override256 public ExecuteSQLAction.Builder sql(BuilderSupport<ExecuteSQLAction.Builder> configurer) {257 ExecuteSQLAction.Builder builder = new ExecuteSQLAction.Builder();258 configurer.configure(builder);259 return run(builder);260 }261 @Override262 public ExecuteSQLQueryAction.Builder query(BuilderSupport<ExecuteSQLQueryAction.Builder> configurer) {263 ExecuteSQLQueryAction.Builder builder = new ExecuteSQLQueryAction.Builder();264 configurer.configure(builder);265 return run(builder);266 }267 @Override268 public FailAction.Builder fail(String message) {269 return run(new FailAction.Builder().message(message));270 }271 @Override272 public InputAction.Builder input(BuilderSupport<InputAction.Builder> configurer) {273 InputAction.Builder builder = new InputAction.Builder();274 configurer.configure(builder);275 return run(builder);276 }277 @Override278 public ReceiveTimeoutAction.Builder receiveTimeout(BuilderSupport<ReceiveTimeoutAction.Builder> configurer) {279 ReceiveTimeoutAction.Builder builder = new ReceiveTimeoutAction.Builder();280 configurer.configure(builder);281 return run(builder);282 }283 @Override284 public LoadPropertiesAction.Builder load(String filePath) {285 LoadPropertiesAction.Builder builder = new LoadPropertiesAction.Builder()286 .filePath(filePath);287 return run(builder);288 }289 @Override290 public PurgeJmsQueuesActionBuilder purgeQueues(BuilderSupport<PurgeJmsQueuesActionBuilder> configurer) {291 PurgeJmsQueuesActionBuilder builder = new PurgeJmsQueuesActionBuilder();292 builder.withReferenceResolver(context.getReferenceResolver());293 configurer.configure(builder);294 return run(builder);295 }296 @Override297 public PurgeMessageChannelActionBuilder purgeChannels(BuilderSupport<PurgeMessageChannelActionBuilder> configurer) {298 PurgeMessageChannelActionBuilder builder = new PurgeMessageChannelActionBuilder();299 builder.channelResolver(context.getReferenceResolver());300 configurer.configure(builder);301 return run(builder);302 }303 @Override304 public PurgeEndpointAction.Builder purgeEndpoints(BuilderSupport<PurgeEndpointAction.Builder> configurer) {305 PurgeEndpointAction.Builder builder = new PurgeEndpointAction.Builder()306 .withReferenceResolver(context.getReferenceResolver());307 configurer.configure(builder);308 return run(builder);309 }310 @Override311 public ReceiveMessageActionBuilder<?> receive(BuilderSupport<ReceiveMessageActionBuilder<?>> configurer) {312 ReceiveMessageActionBuilder<?> builder = new ReceiveMessageActionBuilder<>(new ReceiveMessageAction.Builder()313 .withReferenceResolver(context.getReferenceResolver()));314 configurer.configure(builder);315 return run(builder);316 }317 @Override318 public SendMessageActionBuilder<?> send(BuilderSupport<SendMessageActionBuilder<?>> configurer) {319 SendMessageActionBuilder<?> builder = new SendMessageActionBuilder<>(new SendMessageAction.Builder()320 .withReferenceResolver(context.getReferenceResolver()));321 configurer.configure(builder);322 return run(builder);323 }324 @Override325 public SleepAction.Builder sleep() {326 return run(new SleepAction.Builder());327 }328 @Override329 public SleepAction.Builder sleep(long milliseconds) {330 SleepAction.Builder builder = new SleepAction.Builder()331 .milliseconds(milliseconds);332 return run(builder);333 }334 @Override335 public Wait.Builder waitFor() {336 return new Wait.Builder() {337 @Override338 public WaitActionConditionBuilder execution() {339 final Sequence.Builder dummy = new Sequence.Builder();340 ActionCondition condition = new ActionCondition();341 this.condition = condition;342 DefaultTestRunner.this.containers.push(dummy);343 return new WaitActionConditionBuilder(condition, this) {344 @Override345 public WaitActionConditionBuilder action(TestActionBuilder<?> action) {346 super.action(action);347 DefaultTestRunner.this.containers.remove(dummy);348 return run(this);349 }350 };351 }352 @Override353 public WaitFileConditionBuilder file() {354 FileCondition condition = new FileCondition();355 this.condition = condition;356 return new WaitFileConditionBuilder(condition, this) {357 @Override358 public WaitFileConditionBuilder resource(File file) {359 super.resource(file);360 return run(this);361 }362 };363 }364 @Override365 public WaitHttpConditionBuilder http() {366 HttpCondition condition = new HttpCondition();367 this.condition = condition;368 return new WaitHttpConditionBuilder(condition, this) {369 @Override370 public WaitHttpConditionBuilder url(String requestUrl) {371 super.url(requestUrl);372 return run(this);373 }374 };375 }376 @Override377 public Wait.Builder condition(Condition condition) {378 super.condition(condition);379 return run(this);380 }381 };382 }383 @Override384 public StartServerAction.Builder start(Server... servers) {385 StartServerAction.Builder builder = new StartServerAction.Builder()386 .server(servers);387 return run(builder);388 }389 @Override390 public StartServerAction.Builder start(Server server) {391 StartServerAction.Builder builder = new StartServerAction.Builder()392 .server(server);393 return run(builder);394 }395 @Override396 public StopServerAction.Builder stop(Server... servers) {397 StopServerAction.Builder builder = new StopServerAction.Builder()398 .server(servers);399 return run(builder);400 }401 @Override402 public StopServerAction.Builder stop(Server server) {403 StopServerAction.Builder builder = new StopServerAction.Builder()404 .server(server);405 return run(builder);406 }407 @Override408 public StopTimeAction.Builder stopTime() {409 return run(new StopTimeAction.Builder());410 }411 @Override412 public StopTimeAction.Builder stopTime(String id) {413 StopTimeAction.Builder builder = new StopTimeAction.Builder()414 .id(id);415 return run(builder);416 }417 @Override418 public StopTimeAction.Builder stopTime(String id, String suffix) {419 StopTimeAction.Builder builder = new StopTimeAction.Builder()420 .id(id)421 .suffix(suffix);422 return run(builder);423 }424 @Override425 public TraceVariablesAction.Builder traceVariables() {426 return run(new TraceVariablesAction.Builder());427 }428 @Override429 public TraceVariablesAction.Builder traceVariables(String... variables) {430 TraceVariablesAction.Builder builder = new TraceVariablesAction.Builder()431 .variables(variables);432 return run(builder);433 }434 @Override435 public GroovyAction.Builder groovy(BuilderSupport<GroovyAction.Builder> configurer) {436 GroovyAction.Builder builder = new GroovyAction.Builder();437 configurer.configure(builder);438 return run(builder);439 }440 @Override441 public TransformAction.Builder transform(BuilderSupport<TransformAction.Builder> configurer) {442 TransformAction.Builder builder = new TransformAction.Builder();443 configurer.configure(builder);444 return run(builder);445 }446 @Override447 public Assert.Builder assertException() {448 Assert.Builder builder = new Assert.Builder() {449 @Override450 public Assert.Builder actions(TestActionBuilder<?>... actions) {451 return run(super.actions(actions));452 }453 };454 return container(builder);455 }456 @Override457 public Catch.Builder catchException() {458 Catch.Builder builder = new Catch.Builder() {459 @Override460 public Catch.Builder actions(TestActionBuilder<?>... actions) {461 return run(super.actions(actions));462 }463 };464 return container(builder);465 }466 @Override467 public AssertSoapFaultBuilder assertSoapFault() {468 AssertSoapFaultBuilder builder = new AssertSoapFaultBuilder() {469 @Override470 public AssertSoapFaultBuilder actions(TestActionBuilder<?>... actions) {471 return run(super.actions(actions));472 }473 };474 builder.withReferenceResolver(context.getReferenceResolver());475 return container(builder);476 }477 @Override478 public Conditional.Builder conditional() {479 Conditional.Builder builder = new Conditional.Builder() {480 @Override481 public Conditional.Builder actions(TestActionBuilder<?>... actions) {482 return run(super.actions(actions));483 }484 };485 return container(builder);486 }487 @Override488 public Iterate.Builder iterate() {489 Iterate.Builder builder = new Iterate.Builder() {490 @Override491 public Iterate.Builder actions(TestActionBuilder<?>... actions) {492 return run(super.actions(actions));493 }494 };495 return container(builder);496 }497 @Override498 public Parallel.Builder parallel() {499 Parallel.Builder builder = new Parallel.Builder() {500 @Override501 public Parallel.Builder actions(TestActionBuilder<?>... actions) {502 return run(super.actions(actions));503 }504 };505 return container(builder);506 }507 @Override508 public RepeatOnErrorUntilTrue.Builder repeatOnError() {509 RepeatOnErrorUntilTrue.Builder builder = new RepeatOnErrorUntilTrue.Builder() {510 @Override511 public RepeatOnErrorUntilTrue.Builder actions(TestActionBuilder<?>... actions) {512 return run(super.actions(actions));513 }514 };515 return container(builder);516 }517 @Override518 public RepeatUntilTrue.Builder repeat() {519 RepeatUntilTrue.Builder builder = new RepeatUntilTrue.Builder() {520 @Override521 public RepeatUntilTrue.Builder actions(TestActionBuilder<?>... actions) {522 return run(super.actions(actions));523 }524 };525 return container(builder);526 }527 @Override528 public Sequence.Builder sequential() {529 Sequence.Builder builder = new Sequence.Builder() {530 @Override531 public Sequence.Builder actions(TestActionBuilder<?>... actions) {532 return run(super.actions(actions));533 }534 };535 return container(builder);536 }537 @Override538 public Async.Builder async() {539 Async.Builder builder = new Async.Builder() {540 @Override541 public Async.Builder actions(TestActionBuilder<?>... actions) {542 return run(super.actions(actions));543 }544 };545 return container(builder);546 }547 @Override548 public Timer.Builder timer() {549 Timer.Builder builder = new Timer.Builder() {550 @Override551 public Timer.Builder actions(TestActionBuilder<?>... actions) {552 return run(super.actions(actions));553 }554 };555 return container(builder);556 }557 @Override558 public StopTimerAction.Builder stopTimer(String timerId) {559 StopTimerAction.Builder builder = new StopTimerAction.Builder()560 .id(timerId);561 return run(builder);562 }563 @Override564 public StopTimerAction.Builder stopTimers() {565 return run(new StopTimerAction.Builder());566 }567 @Override568 public DockerExecuteActionBuilder docker(BuilderSupport<DockerExecuteActionBuilder> configurer) {569 DockerExecuteActionBuilder builder = new DockerExecuteActionBuilder();570 configurer.configure(builder);571 return run(builder);572 }573 @Override574 public KubernetesExecuteActionBuilder kubernetes(BuilderSupport<KubernetesExecuteActionBuilder> configurer) {575 KubernetesExecuteActionBuilder builder = new KubernetesExecuteActionBuilder();576 configurer.configure(builder);577 return run(builder);578 }579 @Override580 public SeleniumActionBuilder selenium(BuilderSupport<SeleniumActionBuilder> configurer) {581 SeleniumActionBuilder builder = new SeleniumActionBuilder();582 configurer.configure(builder);583 return run(builder);584 }585 @Override586 public HttpActionBuilder http(BuilderSupport<HttpActionBuilder> configurer) {587 HttpActionBuilder builder = new HttpActionBuilder();588 builder.withReferenceResolver(context.getReferenceResolver());589 configurer.configure(builder);590 return run(builder);591 }592 @Override593 public SoapActionBuilder soap(BuilderSupport<SoapActionBuilder> configurer) {594 SoapActionBuilder builder = new SoapActionBuilder();595 builder.withReferenceResolver(context.getReferenceResolver());596 configurer.configure(builder);597 return run(builder);598 }599 @Override600 public CamelRouteActionBuilder camel(BuilderSupport<CamelRouteActionBuilder> configurer) {601 CamelRouteActionBuilder builder = new CamelRouteActionBuilder();602 builder.withReferenceResolver(context.getReferenceResolver());603 configurer.configure(builder);604 return run(builder);605 }606 @Override607 public ZooExecuteActionBuilder zookeeper(BuilderSupport<ZooExecuteActionBuilder> configurer) {608 ZooExecuteActionBuilder builder = new ZooExecuteActionBuilder();609 builder.withReferenceResolver(context.getReferenceResolver());610 configurer.configure(builder);611 return run(builder);612 }613 @Override614 public Template.Builder applyTemplate(BuilderSupport<Template.Builder> configurer) {615 Template.Builder builder = new Template.Builder()616 .withReferenceResolver(context.getReferenceResolver());617 configurer.configure(builder);618 return run(builder);619 }620 @Override621 public FinallySequence.Builder doFinally() {622 FinallySequence.Builder builder = new FinallySequence.Builder() {623 @Override624 public FinallySequence.Builder actions(TestActionBuilder<?>... actions) {625 return run(super.actions(actions));626 }627 };628 return container(builder);629 }630 /**631 * Gets the test context.632 * @return633 */634 public TestContext getTestContext() {635 return context;636 }637 @Override638 public void setTestContext(TestContext context) {639 this.context = context;640 }641 @Override642 public TestCase getTestCase() {643 testCase.setIncremental(true);644 return testCase;645 }646}...

Full Screen

Full Screen

Source:WaitFileConditionBuilder.java Github

copy

Full Screen

...30 public WaitFileConditionBuilder(FileCondition condition, WaitBuilder builder) {31 super(condition, builder);32 }33 /**34 * Wait for given file path.35 * @param filePath36 * @return37 */38 public Wait path(String filePath) {39 getCondition().setFilePath(filePath);40 return getBuilder().buildAndRun();41 }42 /**43 * Wait for given file resource.44 * @param file45 * @return46 */47 public Wait resource(File file) {48 getCondition().setFile(file);49 return getBuilder().buildAndRun();50 }51}...

Full Screen

Full Screen

path

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.builder;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.exceptions.CitrusRuntimeException;4import com.consol.citrus.util.FileUtils;5import org.slf4j.Logger;6import org.slf4j.LoggerFactory;7import java.io.File;8import java.util.concurrent.TimeUnit;9public class WaitFileConditionBuilder extends AbstractWaitConditionBuilder<WaitFileConditionBuilder> {10 private static Logger log = LoggerFactory.getLogger(WaitFileConditionBuilder.class);11 private final File file;12 public WaitFileConditionBuilder(File file) {13 this.file = file;14 }15 public boolean isSatisfied(TestContext context) {16 boolean satisfied = false;17 try {18 if (file.exists()) {19 log.info(String.format("Found file: '%s'", file.getAbsolutePath()));20 satisfied = true;21 } else {22 log.info(String.format("Waiting for file: '%s'", file.getAbsolutePath()));23 }24 } catch (Exception e) {25 throw new CitrusRuntimeException("Failed to wait for file: " + file.getAbsolutePath(), e);26 }27 return satisfied;28 }29 public WaitFileConditionBuilder timeout(long timeout) {30 super.timeout(timeout);31 return this;32 }33 public WaitFileConditionBuilder pollInterval(long pollInterval) {34 super.pollInterval(pollInterval);35 return this;36 }37 public WaitFileConditionBuilder pollInterval(long pollInterval, TimeUnit timeUnit) {38 super.pollInterval(pollInterval, timeUnit);39 return this;40 }41 public WaitFileConditionBuilder message(String message) {42 super.message(message);43 return this;44 }45 public WaitFileConditionBuilder message(String message, Object... messageArgs) {46 super.message(message, messageArgs);47 return this;48 }49 public WaitFileConditionBuilder message(String message, TestContext context) {

Full Screen

Full Screen

path

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.builder;2import com.consol.citrus.context.TestContext;3import com.consol.citrus.dsl.builder.AbstractWaitConditionBuilder;4import com.consol.citrus.dsl.builder.WaitConditionBuilder;5import com.consol.citrus.dsl.builder.WaitFileConditionBuilder;6import com.consol.citrus.exceptions.CitrusRuntimeException;7import com.consol.citrus.util.FileUtils;8import org.apache.commons.io.filefilter.WildcardFileFilter;9import org.springframework.core.io.Resource;10import java.io.File;11import java.util.ArrayList;12import java.util.Arrays;13import java.util.List;14public class WaitFileConditionBuilder extends AbstractWaitConditionBuilder<WaitFileConditionBuilder> implements WaitConditionBuilder {15 private final List<File> files = new ArrayList<>();16 public WaitFileConditionBuilder(File... files) {17 this.files.addAll(Arrays.asList(files));18 }19 public WaitFileConditionBuilder(Resource... resources) {20 for (Resource resource : resources) {21 if (resource.isFile()) {22 files.add(FileUtils.getFile(resource));23 } else {24 try {25 files.addAll(Arrays.asList(FileUtils.getFiles(resource)));26 } catch (Exception e) {27 throw new CitrusRuntimeException("Failed to read files from resource path: " + resource, e);28 }29 }30 }31 }32 public WaitFileConditionBuilder(String... paths) {33 for (String path : paths) {34 files.add(FileUtils.getFile(path));35 }36 }37 public boolean isSatisfied(TestContext context) {38 for (File file : files) {39 if (!file.exists()) {40 return false;41 }42 }43 return true;44 }45 public String getSuccessMessage(TestContext context) {46 return String.format("Waited for file(s) '%s' to exist", files);47 }48 public String getErrorMessage(TestContext context) {

Full Screen

Full Screen

path

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.builder.WaitFileConditionBuilder;3import com.consol.citrus.dsl.runner.TestRunner;4import com.consol.citrus.dsl.UnitTestSupport;5import com.consol.citrus.exceptions.CitrusRuntimeException;6import org.mockito.Mockito;7import org.testng.Assert;8import org.testng.annotations.Test;9public class WaitFileConditionBuilderTest extends UnitTestSupport {10 private WaitFileConditionBuilder waitFileConditionBuilder = new WaitFileConditionBuilder();11 public void testPath() {12 waitFileConditionBuilder.path("foo/bar");13 Assert.assertEquals(waitFileConditionBuilder.getWaitFileCondition().getPath(), "foo/bar");14 }15 public void testPathWithVariableSupport() {16 waitFileConditionBuilder.path("foo/${bar}");17 Assert.assertEquals(waitFileConditionBuilder.getWaitFileCondition().getPath(), "foo/${bar}");18 }19 public void testPathWithVariables() {20 variables.put("bar", "bar");21 waitFileConditionBuilder.path("foo/${bar}");22 Assert.assertEquals(waitFileConditionBuilder.getWaitFileCondition().getPath(), "foo/bar");23 }24 public void testPathWithTestRunner() {25 TestRunner runner = Mockito.mock(TestRunner.class);26 Mockito.when(runner.replaceDynamicContentInString("foo/${bar}")).thenReturn("foo/bar");27 waitFileConditionBuilder.path("foo/${bar}", runner);28 Assert.assertEquals(waitFileConditionBuilder.getWaitFileCondition().getPath(), "foo/bar");29 }30 public void testPathWithTestRunnerAndVariables() {31 TestRunner runner = Mockito.mock(TestRunner.class);32 Mockito.when(runner.replaceDynamicContentInString("foo/${bar}")).thenReturn("foo/bar");33 variables.put("bar", "bar");34 waitFileConditionBuilder.path("foo/${bar}", runner);35 Assert.assertEquals(waitFileConditionBuilder.getWaitFileCondition().getPath(), "foo/bar");36 }37 public void testPathWithTestRunnerAndNoVariables() {38 TestRunner runner = Mockito.mock(TestRunner.class);39 Mockito.when(runner.replaceDynamicContentInString("foo/${bar}")).thenReturn("foo/${bar}");40 waitFileConditionBuilder.path("foo/${bar}", runner);41 Assert.assertEquals(waitFileConditionBuilder.getWaitFileCondition().getPath(), "foo/${bar}");

Full Screen

Full Screen

path

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.builder.core.BuilderSupport;3import com.consol.citrus.dsl.builder.core.DelegatingTestActionBuilder;4import com.consol.citrus.dsl.builder.core.TestActionBuilder;5import com.consol.citrus.dsl.builder.core.TestActionContainerBuilder;6import com.consol.citrus.dsl.builder.core.TestActionContainerBuilderSupport;7import com.consol.citrus.dsl.builder.core.TestActionListBuilder;8import com.consol.citrus.dsl.builder.core.TestActionSequenceBuilder;9import com.consol.citrus.dsl.builder.core.TestActionTemplateBuilder;10import com.consol.citrus.dsl.builder.core.TestActorBuilder;11import com.consol.citrus.dsl.builder.core.TestBehaviorBuilder;12import com.consol.citrus.dsl.builder.core.TestBehaviorListBuilder;13import com.consol.citrus.dsl.builder.core.TestBehaviorSequenceBuilder;14import com.consol.citrus.dsl.builder.core.TestBehaviorTemplateBuilder;15import com.consol.citrus.dsl.builder.core.TestBuilder;16import com.consol.citrus.dsl.builder.core.TestContainerBuilder;17import com.consol.citrus.dsl.builder.core.TestContainerBuilderSupport;18import com.consol.citrus.dsl.builder.core.TestContainerListBuilder;19import com.consol.citrus.dsl.builder.core.TestContainerSequenceBuilder;20import com.consol.citrus.dsl.builder.core.TestContainerTemplateBuilder;21import com.consol.citrus.dsl.builder.core.TestDesignerBuilder;22import com.consol.citrus.dsl.builder.core.TestDesignerListBuilder;23import com.consol.citrus.dsl.builder.core.TestDesignerSequenceBuilder;24import com.consol.citrus.dsl.builder.core.TestDesignerTemplateBuilder;25import com.consol.citrus.dsl.builder.core.TestRunnerBuilder;26import com.consol.citrus.dsl.builder.core.TestRunnerListBuilder;27import com.consol.citrus.dsl.builder.core.TestRunnerSequenceBuilder;28import com.consol.citrus.dsl.builder.core.TestRunnerTemplateBuilder;29import com.consol.citrus.dsl.builder.core.TestScopeBuilder;30import com.consol.citrus.dsl.builder.core.TestScopeListBuilder;31import com.consol.citrus.dsl.builder.core.TestScopeSequenceBuilder;32import com.consol.citrus.dsl.builder.core.TestScopeTemplateBuilder;33import com.consol.citrus.dsl.builder.core.TestSuiteBuilder;34import com.consol.citrus.dsl.builder.core.TestSuiteListBuilder;35import com

Full Screen

Full Screen

path

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.builder.WaitFileConditionBuilder;3import com.consol.citrus.dsl.design.TestDesigner;4import com.consol.citrus.dsl.design.TestDesignerImpl;5import com.consol.citrus.dsl.runner.TestRunner;6import com.consol.citrus.dsl.runner.TestRunnerImpl;7import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;8import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;9import com.consol.citrus.testng.CitrusParameters;10import org.testng.annotations.Test;11import static com.consol.citrus.actions.CreateVariablesAction.Builder.createVariable;12import static com.consol.citrus.actions.EchoAction.Builder.echo;13import static com.consol.citrus.actions.ExecutePLSQLAction.Builder.executePLSQL;14import static com.consol.citrus.actions.ExecutePLSQLAction.Builder.executePLSQLBuilder;15import static com.consol.citrus.actions.ExecuteSQLAction.Builder.executeSQL;16import static com.consol.citrus.actions.ExecuteSQLQueryAction.Builder.executeSQLQuery;17import static com.consol.citrus.actions.FailAction.Builder.fail;18import static com.consol.citrus.actions.InputAction.Builder.input;19import static com.consol.citrus.actions.PurgeEndpointAction.Builder.purgeEndpoint;20import static com.consol.citrus.actions.ReceiveMessageAction.Builder.receive;21import static com.consol.citrus.actions.SendMessageAction.Builder.send;22import static com.consol.citrus.actions.SleepAction.Builder.sleep;23import static com.consol.citrus.actions.StopTimeAction.Builder.stopTime;24import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeBuilder;25import static com.consol.citrus.actions.StopTimerAction.Builder.stopTimer;26import static com.consol.citrus.actions.StopTimerAction.Builder.stopTimerBuilder;27import static com.consol.citrus.actions.StopTimeAction.Builder.stopTime;28import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeBuilder;29import static com.consol.citrus.actions.StopTimerAction.Builder.stopTimer;30import static com.consol.citrus.actions.StopTimerAction.Builder.stopTimerBuilder;31import static com.consol.citrus.actions.StopTimeAction.Builder.stopTime;32import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeBuilder;33import static com.consol.citrus.actions.StopTimerAction.Builder.stopTimer;34import

Full Screen

Full Screen

path

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.builder.WaitFileConditionBuilder;3import com.consol.citrus.dsl.testng.TestNGCitrusTestBuilder;4import com.consol.citrus.testng.CitrusParameters;5import org.testng.annotations.Test;6public class WaitFileConditionBuilder_Path extends TestNGCitrusTestBuilder {7 public void waitFileConditionBuilder_Path() {8 variable("waitfile", "citrus:file:target/waitfile.txt");9 echo("wait for file in path");10 waitFor()11 .condition(WaitFileConditionBuilder.waitFile()12 .path("${waitfile}")13 .timeout(5000L)14 .interval(1000L)15 .checkInterval(100L)16 .exists(false)17 .run(echo("File does not exist"));18 }19}20package com.consol.citrus.dsl.builder;21import com.consol.citrus.dsl.builder.WaitFileConditionBuilder;22import com.consol.citrus.dsl.testng.TestNGCitrusTestBuilder;23import com.consol.citrus.testng.CitrusParameters;24import org.testng.annotations.Test;25public class WaitFileConditionBuilder_Path extends TestNGCitrusTestBuilder {26 public void waitFileConditionBuilder_Path() {27 variable("waitfile", "citrus:file:target/waitfile.txt");28 echo("wait for file in path");29 waitFor()30 .condition(WaitFileConditionBuilder.waitFile()31 .path("${waitfile}")32 .timeout(5000L)33 .interval(1000L)34 .checkInterval(100L)35 .exists(true)36 .run(echo("File exists"));37 }38}39package com.consol.citrus.dsl.builder;40import com.consol.citrus.dsl.builder.WaitFileConditionBuilder;41import com.consol.citrus.dsl.testng.TestNGCitrusTestBuilder;42import com.consol.cit

Full Screen

Full Screen

path

Using AI Code Generation

copy

Full Screen

1public void path() {2 run(new TestCase() {3 public void run() {4 variable("file", "test.txt");5 variable("path", "C:\\test");6 variable("timeout", "10000");7 variable("interval", "1000");8 variable("fileType", "FILE");9 waitFor()10 .file()11 .path("${path}/${file}")12 .timeout("${timeout}")13 .interval("${interval}")14 .fileType("${fileType}");15 }16 });17}18public void path() {19 run(new TestCase() {20 public void run() {21 variable("file", "test.txt");22 variable("path", "C:\\test");23 variable("timeout", "10000");24 variable("interval", "1000");25 variable("fileType", "FILE");26 waitFor()27 .file()28 .path("${path}/${file}")29 .timeout("${timeout}")30 .interval("${interval}")31 .fileType("${fileType}");32 }33 });34}35public void path() {36 run(new TestCase() {37 public void run() {38 variable("file", "test.txt");39 variable("path", "C:\\test");40 variable("timeout", "10000");41 variable("interval", "1000");42 variable("fileType", "FILE");43 waitFor()44 .file()45 .path("${path}/${file}")46 .timeout("${timeout}")47 .interval("${interval}")48 .fileType("${fileType}");49 }50 });51}52public void path() {53 run(new TestCase() {54 public void run() {55 variable("file", "test.txt

Full Screen

Full Screen

path

Using AI Code Generation

copy

Full Screen

1public void test() {2 variable("file", "D:/test.txt");3 variable("timeout", "10000");4 variable("interval", "1000");5 variable("fileContent", "Hello World");6 variable("fileEncoding", "UTF-8");7 variable("fileType", "text");8 variable("fileMode", "read");9 variable("fileCondition", "exists");10 variable("fileCondition", "contains")

Full Screen

Full Screen

path

Using AI Code Generation

copy

Full Screen

1public void testWaitFile() {2 variable("fileName", "test.txt");3 variable("fileContent", "Hello World!");4 variable("filePath", "src/test/resources");5 variable("fileEncoding", "UTF-8");6 variable("fileTimeout", "10000");7 variable("filePollInterval", "500");8 variable("fileCheckInterval", "500");9 variable("fileDelete", "true");10 variable("fileDeleteOnFail", "false");11 variable("fileIgnoreHiddenFiles", "true");12 variable("fileIgnoreEmptyFiles", "true");13 variable("fileIgnoreMissingDirectories", "true");14 variable("fileIgnoreMissingFiles", "true");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in WaitFileConditionBuilder

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful