<commit_before>package com.microsoft.azure.management.compute.childresource;

import com.microsoft.azure.management.compute.implementation.ExternalChildResourceImpl;
import org.junit.Assert;
import org.junit.Test;
import rx.Observer;
import rx.Subscriber;
import rx.exceptions.CompositeException;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;

public class ExternalChildResourceTests {
    @Test
    public void noCommitIfNoChange() throws InterruptedException {
        ChickenImpl chicken = new ChickenImpl();
        PulletsImpl pullets = chicken.pullets();
        final CountDownLatch monitor = new CountDownLatch(1);
        pullets.commitAsync()
                .subscribe(new Subscriber<PulletImpl>() {
                    @Override
                    public void onCompleted() {
                        monitor.countDown();
                    }

                    @Override
                    public void onError(Throwable throwable) {
                        monitor.countDown();
                        Assert.assertTrue("nothing to commit onError should not be invoked", false);
                    }

                    @Override
                    public void onNext(PulletImpl pullet) {
                        Assert.assertTrue("nothing to commit onNext should not be invoked", false);
                    }
                });
        monitor.await();
    }

    @Test
    public void shouldCommitCreateUpdateAndDelete() throws InterruptedException {
        ChickenImpl chicken = new ChickenImpl();
        chicken
            .defineNewPullet("alice")
                .withAge(1)
                .attach()
            .updatePullet("Clover")
                .withAge(2)
                .attach()
            .withoutPullet("Pinky");

        final List<PulletImpl> changedPuppets = new ArrayList<>();
        final CountDownLatch monitor = new CountDownLatch(1);<commit_msg>attach -> parent<commit_after>package com.microsoft.azure.management.compute.childresource;

import com.microsoft.azure.management.compute.implementation.ExternalChildResourceImpl;
import org.junit.Assert;
import org.junit.Test;
import rx.Observer;
import rx.Subscriber;
import rx.exceptions.CompositeException;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;

public class ExternalChildResourceTests {
    @Test
    public void noCommitIfNoChange() throws InterruptedException {
        ChickenImpl chicken = new ChickenImpl();
        PulletsImpl pullets = chicken.pullets();
        final CountDownLatch monitor = new CountDownLatch(1);
        pullets.commitAsync()
                .subscribe(new Subscriber<PulletImpl>() {
                    @Override
                    public void onCompleted() {
                        monitor.countDown();
                    }

                    @Override
                    public void onError(Throwable throwable) {
                        monitor.countDown();
                        Assert.assertTrue("nothing to commit onError should not be invoked", false);
                    }

                    @Override
                    public void onNext(PulletImpl pullet) {
                        Assert.assertTrue("nothing to commit onNext should not be invoked", false);
                    }
                });
        monitor.await();
    }

    @Test
    public void shouldCommitCreateUpdateAndDelete() throws InterruptedException {
        ChickenImpl chicken = new ChickenImpl();
        chicken
            .defineNewPullet("alice")
                .withAge(1)
                .attach()
            .updatePullet("Clover")
                .withAge(2)
                .parent()
            .withoutPullet("Pinky");

        final List<PulletImpl> changedPuppets = new ArrayList<>();
        final CountDownLatch monitor = new CountDownLatch(1);
{'fraction_non_alphanumeric': 0.08250064053292339, 'fraction_numerical': 0.0020497053548552396, 'mean_word_length': 1.8961424332344214, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, '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': '3409363', 'n_tokens_mistral': 977, 'n_tokens_neox': 924, 'n_words': 214}