Skip to content

Commit 247bda8

Browse files
authored
Merge branch 'iluwatar:master' into master
2 parents 07eb395 + 70fc573 commit 247bda8

File tree

9 files changed

+231
-266
lines changed

9 files changed

+231
-266
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,6 +3068,15 @@
30683068
"translation",
30693069
"review"
30703070
]
3071+
},
3072+
{
3073+
"login": "Romo4ka-bot",
3074+
"name": "Roman Leontev",
3075+
"avatar_url": "https://avatars.githubusercontent.com/u/61774094?v=4",
3076+
"profile": "https://github.com/Romo4ka-bot",
3077+
"contributions": [
3078+
"code"
3079+
]
30713080
}
30723081
],
30733082
"contributorsPerLine": 7,

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
1111
[![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)
1212
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
13-
[![All Contributors](https://img.shields.io/badge/all_contributors-336-orange.svg?style=flat-square)](#contributors-)
13+
[![All Contributors](https://img.shields.io/badge/all_contributors-337-orange.svg?style=flat-square)](#contributors-)
1414
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1515

1616
<br/>
@@ -507,6 +507,9 @@ This project is licensed under the terms of the MIT license.
507507
<td align="center" valign="top" width="14.28%"><a href="https://github.com/drishtii7"><img src="https://avatars.githubusercontent.com/u/82076566?v=4?s=100" width="100px;" alt="drishtii7"/><br /><sub><b>drishtii7</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=drishtii7" title="Code">💻</a></td>
508508
<td align="center" valign="top" width="14.28%"><a href="https://github.com/DavidMedinaO"><img src="https://avatars.githubusercontent.com/u/53974843?v=4?s=100" width="100px;" alt="David Medina Orozco"/><br /><sub><b>David Medina Orozco</b></sub></a><br /><a href="#translation-DavidMedinaO" title="Translation">🌍</a> <a href="https://github.com/iluwatar/java-design-patterns/pulls?q=is%3Apr+reviewed-by%3ADavidMedinaO" title="Reviewed Pull Requests">👀</a></td>
509509
</tr>
510+
<tr>
511+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Romo4ka-bot"><img src="https://avatars.githubusercontent.com/u/61774094?v=4?s=100" width="100px;" alt="Roman Leontev"/><br /><sub><b>Roman Leontev</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=Romo4ka-bot" title="Code">💻</a></td>
512+
</tr>
510513
</tbody>
511514
</table>
512515

api-gateway/price-microservice/src/main/java/com/iluwatar/price/microservice/PriceController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,27 @@
2424
*/
2525
package com.iluwatar.price.microservice;
2626

27-
import lombok.extern.slf4j.Slf4j;
27+
import lombok.RequiredArgsConstructor;
2828
import org.springframework.web.bind.annotation.GetMapping;
2929
import org.springframework.web.bind.annotation.RestController;
3030

3131

3232
/**
3333
* Exposes the Price microservice's endpoints.
3434
*/
35-
@Slf4j
3635
@RestController
36+
@RequiredArgsConstructor
3737
public class PriceController {
3838

39+
private final PriceService priceService;
40+
3941
/**
4042
* An endpoint for a user to retrieve a product's price.
4143
*
4244
* @return A product's price
4345
*/
4446
@GetMapping("/price")
4547
public String getPrice() {
46-
LOGGER.info("Successfully found price info");
47-
return "20";
48+
return priceService.getPrice();
4849
}
4950
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3+
*
4+
* The MIT License
5+
* Copyright © 2014-2022 Ilkka Seppälä
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package com.iluwatar.price.microservice;
26+
27+
/**
28+
* Service to get a product's price.
29+
*/
30+
public interface PriceService {
31+
32+
/**
33+
* Getting the price of a product.
34+
*
35+
* @return A product's price
36+
*/
37+
String getPrice();
38+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3+
*
4+
* The MIT License
5+
* Copyright © 2014-2022 Ilkka Seppälä
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package com.iluwatar.price.microservice;
26+
27+
import lombok.extern.slf4j.Slf4j;
28+
import org.springframework.stereotype.Service;
29+
30+
/**
31+
* {@inheritDoc}
32+
*/
33+
@Service
34+
@Slf4j
35+
public class PriceServiceImpl implements PriceService {
36+
37+
/**
38+
* {@inheritDoc}
39+
*/
40+
@Override
41+
public String getPrice() {
42+
LOGGER.info("Successfully found price info");
43+
return "20";
44+
}
45+
}

api-gateway/price-microservice/src/test/java/com/iluwatar/price/microservice/PriceControllerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
class PriceControllerTest {
3535

3636
@Test
37-
void testgetPrice() {
38-
var priceController = new PriceController();
37+
void getPriceTest() {
38+
var priceController = new PriceController(new PriceServiceImpl());
3939
var price = priceController.getPrice();
4040
assertEquals("20", price);
4141
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3+
*
4+
* The MIT License
5+
* Copyright © 2014-2022 Ilkka Seppälä
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package com.iluwatar.price.microservice;
26+
27+
import org.junit.jupiter.api.Test;
28+
29+
import static org.junit.jupiter.api.Assertions.assertEquals;
30+
31+
/**
32+
* Test for Price Service
33+
*/
34+
class PriceServiceTest {
35+
36+
@Test
37+
void getPriceTest() {
38+
var priceService = new PriceServiceImpl();
39+
var price = priceService.getPrice();
40+
assertEquals("20", price);
41+
}
42+
}

0 commit comments

Comments
 (0)