Skip to content

Commit bf96636

Browse files
Merge branch 'master' into BAEL-778-dep
2 parents 291cd2c + 74aa2c9 commit bf96636

5 files changed

Lines changed: 30 additions & 37 deletions

File tree

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,34 @@
11
package com.baeldung.string;
22

3-
import java.util.HashMap;
43
import java.util.Map;
4+
import java.util.stream.Collectors;
55
import java.util.stream.IntStream;
66
import java.util.stream.Stream;
77

8-
/**
9-
* Created by smatt on 26/05/2017.
10-
*/
118
public class StringToCharStream {
129

13-
public StringToCharStream() {
14-
15-
//let's use the Stream API to manipulate a string
16-
//this will count the occurrence of each character in the test string
17-
10+
private StringToCharStream() {
1811
String testString = "tests";
1912

20-
//first get an IntStream
2113
IntStream intStream = testString.chars();
2214
IntStream intStream1 = testString.codePoints();
2315

24-
//now let's map them
2516
Stream<Character> characterStream = intStream.mapToObj(c -> (char) c);
2617
Stream<Character> characterStream1 = intStream1.mapToObj(c -> (char) c);
2718

2819
System.out.println("Counting Occurrence of Letter");
29-
testString = "Noww";
30-
31-
//we don't want to use foreach, so . . .
32-
33-
Map<Character, Integer> map = new HashMap<>();
3420

35-
testString.codePoints()
36-
.mapToObj(c -> (char) c)
37-
.filter(c -> Character.isLetter(c))
38-
.forEach(c -> {
39-
if(map.containsKey(c)) {
40-
map.put(c, map.get(c) + 1);
41-
} else {
42-
map.put(c, 1);
43-
}
44-
});
21+
Map<Character, Integer> map = "Noww".codePoints()
22+
.mapToObj(c -> (char) c)
23+
.filter(Character::isLetter)
24+
.collect(Collectors.toMap(c -> c, c -> 1, Integer::sum));
4525

4626
//printing out the result here
4727
System.out.println(map.toString());
4828

4929
}
5030

51-
52-
public static void main(String [] args) {
31+
public static void main(String[] args) {
5332
new StringToCharStream();
5433
}
55-
56-
5734
}

‎core-java/src/test/java/com/baeldung/string/StringToCharStreamUnitTest.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010
import static org.junit.Assert.assertThat;
1111
import static org.junit.Assert.assertTrue;
1212

13-
/**
14-
* Created by smatt on 09/06/2017.
15-
*/
1613
public class StringToCharStreamUnitTest {
1714

18-
String testString = "Tests";
15+
private String testString = "Tests";
1916

2017
@Test
2118
public void givenTestString_whenChars_thenReturnIntStream() {
@@ -37,9 +34,9 @@ public void givenIntStream_whenMapToObj_thenReturnCharacterStream() {
3734
}
3835

3936
@Test
40-
public void givenIntStream_whenMapToObj_thenReturnStringStream(){
37+
public void givenIntStream_whenMapToObj_thenReturnStringStream() {
4138
Stream<String> stringStream
42-
= testString.codePoints().mapToObj(c -> String.valueOf((char) c));
39+
= testString.codePoints().mapToObj(c -> String.valueOf((char) c));
4340
assertNotNull(stringStream);
4441
}
4542

‎spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebSocketConfig.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public void configureMessageBroker(final MessageBrokerRegistry config) {
1818

1919
@Override
2020
public void registerStompEndpoints(final StompEndpointRegistry registry) {
21+
registry.addEndpoint("/chat");
2122
registry.addEndpoint("/chat").withSockJS();
2223
}
2324

‎spring-vertx/pom.xml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@
6666
<groupId>org.springframework.boot</groupId>
6767
<artifactId>spring-boot-maven-plugin</artifactId>
6868
</plugin>
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-surefire-plugin</artifactId>
72+
<version>${maven-surefire-plugin.version}</version>
73+
<configuration>
74+
<forkCount>3</forkCount>
75+
<reuseForks>true</reuseForks>
76+
<excludes>
77+
<exclude>**/*IntegrationTest.java</exclude>
78+
<exclude>**/*LongRunningUnitTest.java</exclude>
79+
<exclude>**/*ManualTest.java</exclude>
80+
<exclude>**/JdbcTest.java</exclude>
81+
<exclude>**/*LiveTest.java</exclude>
82+
</excludes>
83+
<testFailureIgnore>true</testFailureIgnore>
84+
</configuration>
85+
</plugin>
6986
</plugins>
7087
</build>
7188

‎spring-vertx/src/test/java/com/baeldung/vertxspring/VertxSpringApplicationIntegrationTest.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ public class VertxSpringApplicationIntegrationTest {
1616
private TestRestTemplate restTemplate = new TestRestTemplate();
1717

1818
@Test
19-
public void givenUrl_whenReceivedArticles_thenSuccess() {
19+
public void givenUrl_whenReceivedArticles_thenSuccess() throws InterruptedException {
2020
ResponseEntity<String> responseEntity = restTemplate.getForEntity("http://localhost:8080/api/baeldung/articles", String.class);
21+
2122
assertEquals(200, responseEntity.getStatusCodeValue());
2223
}
2324

0 commit comments

Comments
 (0)