JAVA-23082 Review log statements for projects - Week 16 - 2023 (moved-13) (conti-1)

This commit is contained in:
timis1 2023-07-10 11:22:34 +03:00 committed by n
parent 9b75a254b9
commit 14e5ed0897
14 changed files with 187 additions and 15 deletions

View File

@ -65,6 +65,7 @@ public class NioVsNio2UnitTest {
public void listFilesUsingWalk() throws Exception {
Path path = Paths.get("src/test");
Stream<Path> walk = Files.walk(path);
walk.forEach(System.out::println);
assertThat(walk.findAny()).isPresent();
}
}

View File

@ -1,57 +1,59 @@
package com.baeldung.streams;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
import java.util.*;
import java.util.stream.IntStream;
import static java.util.stream.Collectors.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class StreamToImmutableUnitTest {
import org.junit.jupiter.api.Test;
class StreamToImmutableUnitTest {
@Test
public void whenUsingCollectingToImmutableSet_thenSuccess() {
void whenUsingCollectingToImmutableSet_thenSuccess() {
List<String> givenList = Arrays.asList("a", "b", "c");
List<String> result = givenList.stream()
.collect(collectingAndThen(toSet(), ImmutableList::copyOf));
System.out.println(result.getClass());
assertEquals("com.google.common.collect.RegularImmutableList", result.getClass().getName());
}
@Test
public void whenUsingCollectingToUnmodifiableList_thenSuccess() {
void whenUsingCollectingToUnmodifiableList_thenSuccess() {
List<String> givenList = new ArrayList<>(Arrays.asList("a", "b", "c"));
List<String> result = givenList.stream()
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
System.out.println(result.getClass());
assertEquals("java.util.Collections$UnmodifiableRandomAccessList", result.getClass().getName());
}
@Test
public void whenCollectToImmutableList_thenSuccess() {
void whenCollectToImmutableList_thenSuccess() {
List<Integer> list = IntStream.range(0, 9)
.boxed()
.collect(ImmutableList.toImmutableList());
System.out.println(list.getClass());
assertEquals("com.google.common.collect.RegularImmutableList", list.getClass().getName());
}
@Test
public void whenCollectToMyImmutableListCollector_thenSuccess() {
void whenCollectToMyImmutableListCollector_thenSuccess() {
List<String> givenList = Arrays.asList("a", "b", "c", "d");
List<String> result = givenList.stream()
.collect(MyImmutableListCollector.toImmutableList());
System.out.println(result.getClass());
assertEquals("java.util.Collections$UnmodifiableRandomAccessList", result.getClass().getName());
}
@Test
public void whenPassingSupplier_thenSuccess() {
void whenPassingSupplier_thenSuccess() {
List<String> givenList = Arrays.asList("a", "b", "c", "d");
List<String> result = givenList.stream()
.collect(MyImmutableListCollector.toImmutableList(LinkedList::new));
System.out.println(result.getClass());
assertEquals("java.util.Collections$UnmodifiableList", result.getClass().getName());
}
}

View File

@ -18,8 +18,8 @@
<AsyncLogger name="org.springframework.beans.factory" level="WARN"/>
<!-- Mule classes -->
<AsyncLogger name="org.mule" level="INFO"/>
<AsyncLogger name="com.mulesoft" level="INFO"/>
<AsyncLogger name="org.mule" level="WARN"/>
<AsyncLogger name="com.mulesoft" level="WARN"/>
<!-- Reduce DM verbosity -->
<AsyncLogger name="org.jetel" level="WARN"/>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.jboss" level="WARN"/>
<logger name="org.apache.deltaspike" level="WARN"/>
<logger name="org.hibernate" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.apache.cassandra.config" level="WARN" />
<logger name="org.apache.cassandra.service" level="WARN" />
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -6,6 +6,10 @@
</encoder>
</appender>
<logger name="org.apache.cassandra.config" level="WARN"/>
<logger name="org.apache.cassandra.service" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="com.netflix" level="WARN"/>
<logger name="org.springframework.boot" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="com.baeldung.cloud.netflix.feign.client" level="INFO"/>
<logger name="org.springframework.core.env" level="WARN"/>
<logger name="org.springframework" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="com.baeldung.cloud.openfeign.client" level="INFO"/>
<logger name="org.eclipse.jetty.server" level="WARN"/>
<logger name="org.springframework" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.springframework" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.apache.zookeeper" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.apache.zookeeper" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<logger name="org.springframework.boot" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="15 seconds" debug="false">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.springframework.boot.test.context" level="WARN"/>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>