Skip to content

Commit 5891d28

Browse files
Merge branch 'master' into patch-3
2 parents 221e07e + 084817f commit 5891d28

File tree

9 files changed

+63
-20
lines changed

9 files changed

+63
-20
lines changed

.all-contributorsrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,6 +3168,33 @@
31683168
"contributions": [
31693169
"code"
31703170
]
3171+
},
3172+
{
3173+
"login": "Xcyq",
3174+
"name": "Xcyq",
3175+
"avatar_url": "https://avatars.githubusercontent.com/u/39086666?v=4",
3176+
"profile": "https://github.com/Xcyq",
3177+
"contributions": [
3178+
"code"
3179+
]
3180+
},
3181+
{
3182+
"login": "Ritabrata1080",
3183+
"name": "Ritabrata",
3184+
"avatar_url": "https://avatars.githubusercontent.com/u/60834250?v=4",
3185+
"profile": "https://github.com/Ritabrata1080",
3186+
"contributions": [
3187+
"review"
3188+
]
3189+
},
3190+
{
3191+
"login": "trivikr",
3192+
"name": "Trivikram Kamat",
3193+
"avatar_url": "https://avatars.githubusercontent.com/u/16024985?v=4",
3194+
"profile": "https://github.com/trivikr",
3195+
"contributions": [
3196+
"code"
3197+
]
31713198
}
31723199
],
31733200
"contributorsPerLine": 6,

.github/workflows/maven-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ jobs:
4242
steps:
4343

4444
- name: Checkout Code
45-
uses: actions/checkout@v3
45+
uses: actions/checkout@v4
4646
with:
4747
# Disabling shallow clone for improving relevancy of SonarQube reporting
4848
fetch-depth: 0
4949

5050
- name: Set up JDK 17
51-
uses: actions/setup-java@v3
51+
uses: actions/setup-java@v4
5252
with:
5353
java-version: '17'
5454
distribution: 'temurin'
5555
cache: 'maven'
5656

5757
- name: Cache local Maven repository
58-
uses: actions/cache@v3
58+
uses: actions/cache@v4
5959
with:
6060
path: ~/.m2/repository
6161
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -64,7 +64,7 @@ jobs:
6464
6565
# Cache Sonar packages which as used to run analysis and collect metrics
6666
- name: Cache SonarCloud packages
67-
uses: actions/cache@v3
67+
uses: actions/cache@v4
6868
with:
6969
path: ~/.sonar/cache
7070
key: ${{ runner.os }}-sonar

.github/workflows/maven-pr-builder.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ jobs:
4242
steps:
4343

4444
- name: Checkout Code
45-
uses: actions/checkout@v3
45+
uses: actions/checkout@v4
4646
with:
4747
ref: ${{ github.event.pull_request.head.sha }}
4848

4949
- name: Set up JDK 17
50-
uses: actions/setup-java@v3
50+
uses: actions/setup-java@v4
5151
with:
5252
java-version: '17'
5353
distribution: 'temurin'
5454
cache: 'maven'
5555

5656
- name: Cache local Maven repository
57-
uses: actions/cache@v3
57+
uses: actions/cache@v4
5858
with:
5959
path: ~/.m2/repository
6060
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -63,7 +63,7 @@ jobs:
6363
6464
# Cache Sonar packages which as used to run analysis and collect metrics
6565
- name: Cache SonarCloud packages
66-
uses: actions/cache@v3
66+
uses: actions/cache@v4
6767
with:
6868
path: ~/.sonar/cache
6969
key: ${{ runner.os }}-sonar

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
77
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
88
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
9-
[![All Contributors](https://img.shields.io/badge/all_contributors-347-orange.svg?style=flat-square)](#contributors-)
9+
[![All Contributors](https://img.shields.io/badge/all_contributors-350-orange.svg?style=flat-square)](#contributors-)
1010
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1111

1212
<br/>
@@ -522,6 +522,11 @@ This project is licensed under the terms of the MIT license.
522522
<td align="center" valign="top" width="16.66%"><a href="https://github.com/romannimets"><img src="https://avatars.githubusercontent.com/u/137268574?v=4?s=100" width="100px;" alt="romannimets"/><br /><sub><b>romannimets</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=romannimets" title="Code">💻</a></td>
523523
<td align="center" valign="top" width="16.66%"><a href="https://github.com/Joel-Dandin"><img src="https://avatars.githubusercontent.com/u/60149879?v=4?s=100" width="100px;" alt="Joel"/><br /><sub><b>Joel</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Joel-Dandin" title="Code">💻</a></td>
524524
<td align="center" valign="top" width="16.66%"><a href="https://github.com/244Walyson"><img src="https://avatars.githubusercontent.com/u/125759796?v=4?s=100" width="100px;" alt="Walyson Moises"/><br /><sub><b>Walyson Moises</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=244Walyson" title="Code">💻</a></td>
525+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/Xcyq"><img src="https://avatars.githubusercontent.com/u/39086666?v=4?s=100" width="100px;" alt="Xcyq"/><br /><sub><b>Xcyq</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Xcyq" title="Code">💻</a></td>
526+
</tr>
527+
<tr>
528+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/Ritabrata1080"><img src="https://avatars.githubusercontent.com/u/60834250?v=4?s=100" width="100px;" alt="Ritabrata"/><br /><sub><b>Ritabrata</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3ARitabrata1080" title="Reviewed Pull Requests">👀</a></td>
529+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/trivikr"><img src="https://avatars.githubusercontent.com/u/16024985?v=4?s=100" width="100px;" alt="Trivikram Kamat"/><br /><sub><b>Trivikram Kamat</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=trivikr" title="Code">💻</a></td>
525530
</tr>
526531
</tbody>
527532
</table>

event-based-asynchronous/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dependency>
4343
<groupId>org.awaitility</groupId>
4444
<artifactId>awaitility</artifactId>
45-
<version>4.2.1</version>
45+
<version>4.2.2</version>
4646
<scope>test</scope>
4747
</dependency>
4848
</dependencies>

partial-response/src/main/java/com/iluwatar/partialresponse/FieldJsonMapper.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package com.iluwatar.partialresponse;
2626

2727
import java.lang.reflect.Field;
28+
import java.util.StringJoiner;
2829

2930
/**
3031
* Map a video to json.
@@ -39,18 +40,15 @@ public class FieldJsonMapper {
3940
* @return json of required fields from video
4041
*/
4142
public String toJson(Video video, String[] fields) throws Exception {
42-
var json = new StringBuilder().append("{");
43+
var json = new StringJoiner(",", "{", "}");
4344

4445
var i = 0;
4546
var fieldsLength = fields.length;
4647
while (i < fieldsLength) {
47-
json.append(getString(video, Video.class.getDeclaredField(fields[i])));
48-
if (i != fieldsLength - 1) {
49-
json.append(",");
50-
}
48+
json.add(getString(video, Video.class.getDeclaredField(fields[i])));
5149
i++;
5250
}
53-
json.append("}");
51+
5452
return json.toString();
5553
}
5654

partial-response/src/main/java/com/iluwatar/partialresponse/Video.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public String toString() {
4343
+ "\"length\": " + length + ","
4444
+ "\"description\": \"" + description + "\","
4545
+ "\"director\": \"" + director + "\","
46-
+ "\"language\": \"" + language + "\","
46+
+ "\"language\": \"" + language + "\""
4747
+ "}";
4848
}
4949
}

partial-response/src/test/java/com/iluwatar/partialresponse/VideoResourceTest.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void shouldGiveVideoDetailsById() throws Exception {
6363
var actualDetails = resource.getDetails(1);
6464

6565
var expectedDetails = "{\"id\": 1,\"title\": \"Avatar\",\"length\": 178,\"description\": "
66-
+ "\"epic science fiction film\",\"director\": \"James Cameron\",\"language\": \"English\",}";
66+
+ "\"epic science fiction film\",\"director\": \"James Cameron\",\"language\": \"English\"}";
6767
Assertions.assertEquals(expectedDetails, actualDetails);
6868
}
6969

@@ -78,4 +78,17 @@ void shouldGiveSpecifiedFieldsInformationOfVideo() throws Exception {
7878

7979
Assertions.assertEquals(expectedDetails, actualFieldsDetails);
8080
}
81-
}
81+
82+
@Test
83+
void shouldAllSpecifiedFieldsInformationOfVideo() throws Exception {
84+
var fields = new String[]{"id", "title", "length", "description", "director", "language"};
85+
86+
var expectedDetails = "{\"id\": 1,\"title\": \"Avatar\",\"length\": 178,\"description\": "
87+
+ "\"epic science fiction film\",\"director\": \"James Cameron\",\"language\": \"English\"}";
88+
Mockito.when(fieldJsonMapper.toJson(any(Video.class), eq(fields))).thenReturn(expectedDetails);
89+
90+
var actualFieldsDetails = resource.getDetails(1, fields);
91+
92+
Assertions.assertEquals(expectedDetails, actualFieldsDetails);
93+
}
94+
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
4949
<license-maven-plugin.version>4.5</license-maven-plugin.version>
5050
<urm-maven-plugin.version>2.1.1</urm-maven-plugin.version>
51-
<slf4j.version>2.0.13</slf4j.version>
51+
<slf4j.version>2.0.16</slf4j.version>
5252
<logback.version>1.5.6</logback.version>
5353
<!-- SonarCloud -->
5454
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

0 commit comments

Comments
 (0)