<commit_before>package com.contaazul.turbine.ec2;

import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.ec2.model.InstanceState;
import com.amazonaws.services.ec2.model.InstanceStateName;
import com.amazonaws.services.ec2.model.Tag;
import org.assertj.core.api.Assertions;
import org.junit.Test;

/**
 * Test case for {@link EC2ToTurbineInstance}.
 * @author <NAME>
 */
public final class EC2ToTurbineInstanceTest {
    /**
     * {@link EC2ToTurbineInstance} can convert a running ec2 instance into
     * a turbine instance.
     */
    @Test
    public void convertsRunningInstances() {
        final String ip = "192.168.3.11";
        final String cluster = "blah";
        final Instance ec2 = new Instance()
            .withPrivateIpAddress(ip)
            .withState(new InstanceState().withName(InstanceStateName.Running));
        Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
            .isNotNull()
            .matches(instance -> instance.getHostname().equals(ip))
            .matches(com.netflix.turbine.discovery.Instance::isUp);
    }

    /**
     * {@link EC2ToTurbineInstance} can convert a running ec2 instance into
     * a turbine instance with its name as address.
     */
    @Test
    public void convertsRunningInstancesWithName() {
        final String ip = "192.168.3.11";
        final String name = "localhost";
        final String cluster = "blah";
        final Instance ec2 = new Instance()
                .withPrivateIpAddress(ip)
                .withTags(new Tag("Name", name))
                .withState(new InstanceState().withName(InstanceStateName.Running));
        Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
                .isNotNull()
                .matches(instance -> instance.getHostname().equals(name))
                .matches(com.netflix.turbine.discovery.Instance::isUp);
    }

    /**
     * {@link EC2ToTurbineInstance} can convert a running ec2 instance into
     * a turbine instance with an invalid name as address.
     */
    @Test
    public void convertsRunningInstancesWithInvalidName() {
        final String ip = "192.168.3.11";
        final String name = "google.com";
        final String cluster = "blah";
        final Instance ec2 = new Instance()
                .withPrivateIpAddress(ip)
                .withTags(new Tag("Name", name))
                .withState(new InstanceState().withName(InstanceStateName.Running));
        Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
                .isNotNull()
                .matches(instance -> instance.getHostname().equals(ip))
                .matches(com.netflix.turbine.discovery.Instance::isUp);
    }

    /**
     * {@link EC2ToTurbineInstance} can convert a non running ec2 instance into
     * a turbine instance.
     */
    @Test
    public void convertsNonRunningInstances() {
        final String ip = "172.16.17.32";
        final String cluster = "blah";
        final Instance ec2 = new Instance()
            .withPrivateIpAddress(ip)
            .withState(new InstanceState().withName(InstanceStateName.Pending));
        Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
            .isNotNull()
            .matches(instance -> instance.getHostname().equals(ip))
            .matches(instance -> !instance.isUp());
    }
}<commit_msg>fix tests on travis, maybe<commit_after>package com.contaazul.turbine.ec2;

import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.ec2.model.InstanceState;
import com.amazonaws.services.ec2.model.InstanceStateName;
import com.amazonaws.services.ec2.model.Tag;
import org.assertj.core.api.Assertions;
import org.junit.Test;

/**
 * Test case for {@link EC2ToTurbineInstance}.
 * @author <NAME>
 */
public final class EC2ToTurbineInstanceTest {
    /**
     * {@link EC2ToTurbineInstance} can convert a running ec2 instance into
     * a turbine instance.
     */
    @Test
    public void convertsRunningInstances() {
        final String ip = "192.168.3.11";
        final String cluster = "blah";
        final Instance ec2 = new Instance()
            .withPrivateIpAddress(ip)
            .withState(new InstanceState().withName(InstanceStateName.Running));
        Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
            .isNotNull()
            .matches(instance -> instance.getHostname().equals(ip))
            .matches(com.netflix.turbine.discovery.Instance::isUp);
    }

    /**
     * {@link EC2ToTurbineInstance} can convert a running ec2 instance into
     * a turbine instance with its name as address.
     */
    @Test
    public void convertsRunningInstancesWithName() {
        final String ip = "192.168.3.11";
        final String name = "google.com";
        final String cluster = "blah";
        final Instance ec2 = new Instance()
                .withPrivateIpAddress(ip)
                .withTags(new Tag("Name", name))
                .withState(new InstanceState().withName(InstanceStateName.Running));
        Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
                .isNotNull()
                .matches(instance -> instance.getHostname().equals(name))
                .matches(com.netflix.turbine.discovery.Instance::isUp);
    }

    /**
     * {@link EC2ToTurbineInstance} can convert a running ec2 instance into
     * a turbine instance with an invalid name as address.
     */
    @Test
    public void convertsRunningInstancesWithInvalidName() {
        final String ip = "192.168.3.11";
        final String name = "asdasdasdasdasda";
        final String cluster = "blah";
        final Instance ec2 = new Instance()
                .withPrivateIpAddress(ip)
                .withTags(new Tag("Name", name))
                .withState(new InstanceState().withName(InstanceStateName.Running));
        Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
                .isNotNull()
                .matches(instance -> instance.getHostname().equals(ip))
                .matches(com.netflix.turbine.discovery.Instance::isUp);
    }

    /**
     * {@link EC2ToTurbineInstance} can convert a non running ec2 instance into
     * a turbine instance.
     */
    @Test
    public void convertsNonRunningInstances() {
        final String ip = "172.16.17.32";
        final String cluster = "blah";
        final Instance ec2 = new Instance()
            .withPrivateIpAddress(ip)
            .withState(new InstanceState().withName(InstanceStateName.Pending));
        Assertions.assertThat(new EC2ToTurbineInstance(cluster).convert(ec2))
            .isNotNull()
            .matches(instance -> instance.getHostname().equals(ip))
            .matches(instance -> !instance.isUp());
    }
}
{'fraction_non_alphanumeric': 0.11142020497803806, 'fraction_numerical': 0.018448023426061493, 'mean_word_length': 2.54488842760768, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, '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': '5632657', 'n_tokens_mistral': 1982, 'n_tokens_neox': 1910, 'n_words': 412}