chore: remove obsolete application and collector classes
This commit is contained in:
@@ -1,45 +0,0 @@
|
|||||||
package ru.project;
|
|
||||||
|
|
||||||
import com.googlecode.lanterna.gui2.MultiWindowTextGUI;
|
|
||||||
import com.googlecode.lanterna.screen.Screen;
|
|
||||||
import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
|
|
||||||
import ru.project.model.AppState;
|
|
||||||
import ru.project.ui.main.MainMenu;
|
|
||||||
|
|
||||||
public final class App {
|
|
||||||
|
|
||||||
private App() {}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
Screen screen = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
DefaultTerminalFactory terminalFactory = new DefaultTerminalFactory();
|
|
||||||
|
|
||||||
screen = terminalFactory.createScreen();
|
|
||||||
screen.startScreen();
|
|
||||||
|
|
||||||
MultiWindowTextGUI gui = new MultiWindowTextGUI(screen);
|
|
||||||
|
|
||||||
AppState state = new AppState();
|
|
||||||
|
|
||||||
MainMenu mainMenu = new MainMenu(gui, state);
|
|
||||||
|
|
||||||
mainMenu.showModal();
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Произошла ошибка при выполнении программы:");
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (screen != null) {
|
|
||||||
try {
|
|
||||||
screen.stopScreen();
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Не удалось корректно завершить работу терминала:");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package ru.test.maven.spring;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
public class MyCollectors
|
|
||||||
{
|
|
||||||
private MyCollectors() {
|
|
||||||
}
|
|
||||||
public static <T> Collector<T, MyList<T>, MyList<T>> toMyList() {
|
|
||||||
return new MyListCollector<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package ru.test.maven.spring;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.BinaryOperator;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
public class MyListCollector <T> implements Collector<T, MyList<T>, MyList<T>>
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Supplier<MyList<T>> supplier()
|
|
||||||
{
|
|
||||||
return () -> new MyLinkedList<>();
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public BiConsumer<MyList<T>, T> accumulator() {
|
|
||||||
|
|
||||||
return (list, element) -> list.add(element);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public BinaryOperator<MyList<T>> combiner() {
|
|
||||||
return (list1, list2) -> {
|
|
||||||
for (int i = 0; i < list2.size(); i++) {
|
|
||||||
list1.add(list2.get(i));
|
|
||||||
}
|
|
||||||
return list1;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Function<MyList<T>, MyList<T>> finisher()
|
|
||||||
{
|
|
||||||
return list -> list;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public Set<Collector.Characteristics> characteristics() {
|
|
||||||
return java.util.Set.of(
|
|
||||||
Collector.Characteristics.IDENTITY_FINISH
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package ru.project;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
/** Unit test for simple App. */
|
|
||||||
public class AppTest {
|
|
||||||
|
|
||||||
/** Rigorous Test :-) */
|
|
||||||
@Test
|
|
||||||
public void shouldAnswerWithTrue() {
|
|
||||||
assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package ru.test.maven.spring;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
import java.util.Collections;
|
|
||||||
public class MyListCollectorTest
|
|
||||||
{
|
|
||||||
private final MyListCollector<Integer> collector = new MyListCollector<>();
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void shouldTestCollectInOrderSequential() {
|
|
||||||
MyList<Integer> result = IntStream.range(0, 10)
|
|
||||||
.boxed()
|
|
||||||
.collect(MyCollectors.toMyList());
|
|
||||||
|
|
||||||
assertEquals(10, result.size());
|
|
||||||
for (int i = 0; i < result.size(); i++) {
|
|
||||||
assertEquals(i, (int) result.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void shouldTestCollectInOrderParallel() {
|
|
||||||
MyList<Integer> result = IntStream.range(0, 100)
|
|
||||||
.parallel()
|
|
||||||
.boxed()
|
|
||||||
.collect(MyCollectors.toMyList());
|
|
||||||
|
|
||||||
assertEquals(100, result.size());
|
|
||||||
for (int i = 0; i < result.size(); i++) {
|
|
||||||
assertEquals(i, (int) result.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void shouldTestHandleEmptyStream() {
|
|
||||||
MyList<Integer> result = IntStream.empty()
|
|
||||||
.boxed()
|
|
||||||
.collect(MyCollectors.toMyList());
|
|
||||||
|
|
||||||
assertTrue(result.isEmpty());
|
|
||||||
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
void shouldTestNotUseStandardList() {
|
|
||||||
MyList<String> result = IntStream.range(0, 5)
|
|
||||||
.mapToObj(i -> "item" + i)
|
|
||||||
.collect(MyCollectors.toMyList());
|
|
||||||
|
|
||||||
assertInstanceOf(MyList.class, result);
|
|
||||||
assertFalse(result instanceof java.util.List);
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
void shouldTestHaveCorrectCharacteristics() {
|
|
||||||
Set<Collector.Characteristics> characteristics = collector.characteristics();
|
|
||||||
assertTrue(characteristics.contains(java.util.stream.Collector.Characteristics.IDENTITY_FINISH));
|
|
||||||
assertFalse(characteristics.contains(java.util.stream.Collector.Characteristics.UNORDERED));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user