<commit_before>package org.ow2.choreos.deployment.nodes.cloudprovider;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.concurrent.atomic.AtomicInteger;

import org.junit.Test;

public class DelayedRequestsEnforcerTest {

    private static final int WAIT_TIME = 100;

    private DelayedRequestEnforcer enforcer = new DelayedRequestEnforcer(WAIT_TIME);
    private AtomicInteger counter = new AtomicInteger();

    @Test
    public void shouldEnforceRule() {

        final int N = 30;
        for (int i = 0; i < N; i++) {
            Task task = new Task();
            Thread trd = new Thread(task);
            trd.start();
        }

        long t0 = System.nanoTime();
        
        int previous = 0;
        int value = counter.get();
        while (value < N - 1) { 
            if (value > previous + 2)
                fail();
            waitTimeBetweenRequests();
            if (value > previous)
                previous = value;
            value = counter.get();
        }
        
        long tf = System.nanoTime();
        long deltaMilli = (tf - t0) / 1000000;
        assertTrue(deltaMilli >= N * WAIT_TIME);
    }
    
    private void waitTimeBetweenRequests() {
        try {
            Thread.sleep(WAIT_TIME);
        } catch (InterruptedException e) {
            ;
        }
    }

    private class Task implements Runnable {
        @Override
        public void run() {
            enforcer.enforceRule();
            counter.getAndIncrement();
        }
    }

}
<commit_msg>changing test that was not good<commit_after>package org.ow2.choreos.deployment.nodes.cloudprovider;

import static org.junit.Assert.fail;

import java.util.concurrent.atomic.AtomicInteger;

import org.junit.Test;

public class DelayedRequestsEnforcerTest {

    private static final int WAIT_TIME = 100;

    private DelayedRequestEnforcer enforcer = new DelayedRequestEnforcer(WAIT_TIME);
    private AtomicInteger counter = new AtomicInteger();

    @Test
    public void shouldEnforceRule() {

        final int N = 30;
        for (int i = 0; i < N; i++) {
            Task task = new Task();
            Thread trd = new Thread(task);
            trd.start();
        }

        int previous = 0;
        int value = counter.get();
        while (value < N - 1) { 
            if (value > previous + 2)
                fail();
            waitTimeBetweenRequests();
            if (value > previous)
                previous = value;
            value = counter.get();
        }
    }
    
    private void waitTimeBetweenRequests() {
        try {
            Thread.sleep(WAIT_TIME);
        } catch (InterruptedException e) {
            ;
        }
    }

    private class Task implements Runnable {
        @Override
        public void run() {
            enforcer.enforceRule();
            counter.getAndIncrement();
        }
    }

}

{'fraction_non_alphanumeric': 0.09468267581475129, 'fraction_numerical': 0.009948542024013723, 'mean_word_length': 1.8065447545717035, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4633320', 'n_tokens_mistral': 856, 'n_tokens_neox': 806, 'n_words': 210}