/
NikolayIvkin
/
tutorials1
Обзор
Документация
Войти
/
NikolayIvkin
/
tutorials1
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
libraries-data/src/test/java/com/baeldung/crunch/ToUpperCaseWithCounterFnUnitTest.java
32 строки
1 KB
panos-kakos
[JAVA-18177] Moved server modules to jdk9-and-above profile (#13523)
26 фев 2023, 19:25
26 фев 2023, 19:25
428f69a
Код
Авторство
О чём код?
package com.baeldung.crunch; import static org.junit.Assert.assertEquals; import org.apache.crunch.PCollection; import org.apache.crunch.impl.mem.MemPipeline; import org.apache.crunch.types.writable.Writables; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; public class ToUpperCaseWithCounterFnUnitTest { @Before public void setUp() throws Exception { MemPipeline.clearCounters(); } @Test public void whenFunctionCalled_counterIncementendForChangedValues() { PCollection<String> inputStrings = MemPipeline.collectionOf("This", "is", "a", "TEST", "string"); PCollection<String> upperCaseStrings = inputStrings.parallelDo(new ToUpperCaseWithCounterFn(), Writables.strings()); assertEquals(ImmutableList.of("THIS", "IS", "A", "TEST", "STRING"), Lists.newArrayList(upperCaseStrings.materialize())); assertEquals(4L, MemPipeline.getCounters() .findCounter("UpperCase", "modified") .getValue()); } }