<commit_before>/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
package org.elasticsearch.watcher;

import com.carrotsearch.randomizedtesting.annotations.Repeat;
import org.elasticsearch.test.ElasticsearchTestCase;
import org.junit.Test;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

/**
 *
 */
public class WatcherVersionTests extends ElasticsearchTestCase {

    @Test
    @Repeat(iterations = 100)
    public void testStrings() throws Exception {
        boolean beta = randomBoolean();
        int buildNumber = beta ? randomIntBetween(0, 49) : randomIntBetween(0, 48);
        int major = randomIntBetween(0, 20);
        int minor = randomIntBetween(0, 20);
        int revision = randomIntBetween(0, 20);

        String build = buildNumber == 0 ? "" :
                beta ? "-beta" + buildNumber : "-rc" + buildNumber;


        String versionName = new StringBuilder()
                .append(major)
                .append(".").append(minor)
                .append(".").append(revision)
                .append(build).toString();
        WatcherVersion version = WatcherVersion.fromString(versionName);

        logger.info("version: {}", versionName);

        assertThat(version.major, is((byte) major));
        assertThat(version.minor, is((byte) minor));
        assertThat(version.revision, is((byte) revision));
        if (buildNumber == 0) {
            assertThat(version.build, is((byte) 99));
        } else if (beta) {
            assertThat(version.build, is((byte) buildNumber));
        } else {
            assertThat(version.build, is((byte) (buildNumber + 50)));
        }

        assertThat(version.number(), equalTo(versionName));
    }
}<commit_msg>remove @Repeat annotation from test<commit_after>/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */
package org.elasticsearch.watcher;

import org.elasticsearch.test.ElasticsearchTestCase;
import org.junit.Test;

import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;

/**
 *
 */
public class WatcherVersionTests extends ElasticsearchTestCase {

    @Test
    public void testStrings() throws Exception {
        for (int i = 0; i < 100; i++) {
            boolean beta = randomBoolean();
            int buildNumber = beta ? randomIntBetween(0, 49) : randomIntBetween(0, 48);
            int major = randomIntBetween(0, 20);
            int minor = randomIntBetween(0, 20);
            int revision = randomIntBetween(0, 20);

            String build = buildNumber == 0 ? "" :
                    beta ? "-beta" + buildNumber : "-rc" + buildNumber;


            String versionName = new StringBuilder()
                    .append(major)
                    .append(".").append(minor)
                    .append(".").append(revision)
                    .append(build).toString();
            WatcherVersion version = WatcherVersion.fromString(versionName);

            logger.info("version: {}", versionName);

            assertThat(version.major, is((byte) major));
            assertThat(version.minor, is((byte) minor));
            assertThat(version.revision, is((byte) revision));
            if (buildNumber == 0) {
                assertThat(version.build, is((byte) 99));
            } else if (beta) {
                assertThat(version.build, is((byte) buildNumber));
            } else {
                assertThat(version.build, is((byte) (buildNumber + 50)));
            }

            assertThat(version.number(), equalTo(versionName));
        }
    }
}
{'fraction_non_alphanumeric': 0.11746680286006128, 'fraction_numerical': 0.01251276813074566, 'mean_word_length': 2.481777777777778, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, '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': '2891999', 'n_tokens_mistral': 1081, 'n_tokens_neox': 1022, 'n_words': 273}