-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from NashTech-Labs/feature/sonar-integration
Feature/sonar integration
- Loading branch information
Showing
4 changed files
with
282 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
cart-service/src/main/resources/spotbugs/spotbugs-security-exclude.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<FindBugsFilter> | ||
<Match> | ||
<Bug pattern="EI_EXPOSE_REP"/> | ||
</Match> | ||
</FindBugsFilter> |
5 changes: 5 additions & 0 deletions
5
cart-service/src/main/resources/spotbugs/spotbugs-security-include.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<FindBugsFilter> | ||
<Match> | ||
<Bug category="SECURITY"/> | ||
</Match> | ||
</FindBugsFilter> |
46 changes: 46 additions & 0 deletions
46
cart-service/src/test/java/com/nashtech/car/cart/service/CartServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.nashtech.car.cart.service; | ||
|
||
|
||
import com.nashtech.car.cart.model.CartItem; | ||
import com.nashtech.car.cart.repository.CartItemRepository; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.mockito.ArgumentMatchers.anyString; | ||
|
||
class CartServiceTest { | ||
|
||
@Mock | ||
private CartItemRepository cartItemRepository; | ||
|
||
@InjectMocks | ||
private CartService cartService; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
MockitoAnnotations.openMocks(this); | ||
} | ||
|
||
@Test | ||
void testGetFromCart() { | ||
CartItem cartItem = new CartItem(); | ||
cartItem.setProductId("123"); | ||
List<CartItem> cartItemList = Collections.singletonList(cartItem); | ||
Mockito.when(cartItemRepository.findByUserId(anyString())).thenReturn(cartItemList); | ||
|
||
List<CartItem> result = cartService.getFromCart("user1"); | ||
|
||
Assertions.assertNotNull(result); | ||
Assertions.assertEquals(1, result.size()); | ||
Assertions.assertEquals("123", result.get(0).getProductId()); | ||
} | ||
} | ||
|