<commit_before>package org.sitoolkit.wt.gui.app.update;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;

import java.io.File;
import java.net.URISyntaxException;

import org.junit.BeforeClass;
import org.junit.Test;
import org.sitoolkit.wt.gui.infra.maven.MavenUtils;

public class UpdateServiceTest {

    UpdateService service = new UpdateService();

    private volatile boolean testing = true;

    @BeforeClass
    public static void setup() {
        MavenUtils.findAndInstall();
        MavenUtils.downloadRepository();
    }

    @Test
    public void testCheckAppUpdate() throws URISyntaxException, InterruptedException {

        File pomFile = new File(getClass().getResource("pom.xml").toURI());

        service.checkSitWtAppUpdate(pomFile, newVersion -> {
            assertThat("newVersion", newVersion, is("1.2"));
            testing = false;
        });

        while (testing) {
        }
    }

    @Test
    public void testDownload() {

        service.downloadSitWtApp(new File("target"), "1.2", downloadedFile -> {
            downloadedFile.deleteOnExit();
            assertThat("file downloaded", downloadedFile.exists(), is(true));
            testing = false;
        });

        while (testing) {
        }
    }

}<commit_msg>assert NGの場合にテストがハングする問題を修正<commit_after>package org.sitoolkit.wt.gui.app.update;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;

import java.io.File;
import java.net.URISyntaxException;

import org.junit.BeforeClass;
import org.junit.Test;
import org.sitoolkit.wt.gui.infra.maven.MavenUtils;
import org.sitoolkit.wt.gui.test.ThreadUtils;

public class UpdateServiceTest {

    UpdateService service = new UpdateService();

    private volatile boolean tested = false;

    @BeforeClass
    public static void setup() {
        MavenUtils.findAndInstall();
        MavenUtils.downloadRepository();
    }

    @Test
    public void testCheckAppUpdate() throws URISyntaxException, InterruptedException {

        File pomFile = new File(getClass().getResource("pom.xml").toURI());

        service.checkSitWtAppUpdate(pomFile, newVersion -> {
            // TODO newVersionの値をpomから取得
            assertThat("newVersion", newVersion, is("2.0"));
            tested = true;
        });

        ThreadUtils.waitFor(() -> tested);
    }

    @Test
    public void testDownload() {

        service.downloadSitWtApp(new File("target"), "1.2", downloadedFile -> {
            downloadedFile.deleteOnExit();
            assertThat("file downloaded", downloadedFile.exists(), is(true));
            tested = true;
        });

        ThreadUtils.waitFor(() -> tested);
    }

}
{'fraction_non_alphanumeric': 0.11738648947951273, 'fraction_numerical': 0.0029531192321889995, 'mean_word_length': 2.9048991354466858, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4743605', 'n_tokens_mistral': 816, 'n_tokens_neox': 779, 'n_words': 153}