/*
 * Copyright 2014 Mariusz.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.watchrabbit.executor.command;

import com.watchrabbit.commons.exception.SystemException;
import static com.watchrabbit.executor.wrapper.RetryConfig.retry;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;

/**
 *
 * @author Mariusz
 */
public class RetryTest {

    @Test(timeout = 200)
    public void shoudlInvokeTwice() throws ExecutionException {
        CountDownLatch latch = new CountDownLatch(2);

        String invoke = ExecutorCommand.<String>executor("")
                .withBreakerRetryTimeout(-1, TimeUnit.MILLISECONDS)
                .withRetry(
                        retry()
                        .withRetryInterval(10, TimeUnit.MILLISECONDS)
                ).invoke(
                        () -> {
                            latch.countDown();
                            if (latch.getCount() == 1) {
                                throw new SystemException();
                            } else {
                                return "abc";
                            }
                        }
                );

        assertThat(latch.getCount()).isEqualTo(0);
        assertThat(invoke).isEqualTo("abc");
    }
}

@@ -1223,16 +1223,33 @@
 ecutor(%22
+shoudlInvokeTwice
 %22)%0A     

Test fixes