<commit_before>// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc.metric;

import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.application.MetricConsumer;
import com.yahoo.jdisc.core.ActiveContainerStatistics;
import org.junit.Test;
import org.mockito.Mockito;

import static org.junit.Assert.assertTrue;

public class MetricUpdaterTest {
    
    @Test
    public void testFreeMemory() throws InterruptedException {
        MetricConsumer consumer = Mockito.mock(MetricConsumer.class);
        MetricProvider provider = MetricProviders.newInstance(consumer);

        Metric metric = provider.get();
        MetricUpdater updater = new MetricUpdater(metric, Mockito.mock(ActiveContainerStatistics.class), 10);
        long start = System.currentTimeMillis();
        boolean updated = false;
        while (System.currentTimeMillis() - start < 60000 && !updated) {
            Thread.sleep(10);
            if (memoryMetricsUpdated(updater)) {
                updated = true;<commit_msg>Revert "Mock ActiveContainerStatistics as its constructor is package-private"<commit_after>// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.jdisc.metric;

import com.yahoo.jdisc.Metric;
import com.yahoo.jdisc.application.MetricConsumer;
import com.yahoo.jdisc.core.ActiveContainerStatistics;
import org.junit.Test;
import org.mockito.Mockito;

import static org.junit.Assert.assertTrue;

public class MetricUpdaterTest {
    
    @Test
    public void testFreeMemory() throws InterruptedException {
        MetricConsumer consumer = Mockito.mock(MetricConsumer.class);
        MetricProvider provider = MetricProviders.newInstance(consumer);

        Metric metric = provider.get();
        MetricUpdater updater = new MetricUpdater(metric, new ActiveContainerStatistics(), 10);
        long start = System.currentTimeMillis();
        boolean updated = false;
        while (System.currentTimeMillis() - start < 60000 && !updated) {
            Thread.sleep(10);
            if (memoryMetricsUpdated(updater)) {
                updated = true;
{'fraction_non_alphanumeric': 0.08857913669064749, 'fraction_numerical': 0.013489208633093525, 'mean_word_length': 3.578189300411523, 'pattern_counts': {'":': 0, '<': 5, '<?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': '537661', 'n_tokens_mistral': 626, 'n_tokens_neox': 582, 'n_words': 157}