Skip to content

Commit

Permalink
issue #1168: update IT test
Browse files Browse the repository at this point in the history
  • Loading branch information
DinhThaiVV committed Oct 30, 2024
1 parent 1f15df4 commit 17e26f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,13 @@ void test_getProductListBackoffice_shouldReturnProductList() {
}

@Test
void test_getProductFeature_shouldReturnProductList() {
void test_getProductFeature_shouldReturnEmptyList() {
getGivenSpecificationWithAdmin()
.when()
.get(PRODUCT_STOREFRONT_URL + "/featured")
.then()
.statusCode(HttpStatus.OK.value())

Check failure on line 223 in product/src/it/java/com/yas/product/controller/ProductControllerIT.java

View workflow job for this annotation

GitHub Actions / Product-Service-Unit-Test-Results

com.yas.product.controller.ProductControllerIT ► test_getProductFeature_shouldReturnEmptyList

Failed test found in: product/target/failsafe-reports/TEST-com.yas.product.controller.ProductControllerIT.xml Error: java.lang.AssertionError:
Raw output
java.lang.AssertionError: 
1 expectation failed.
Expected status code <200> but was <500>.

	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:73)
	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:108)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:263)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:277)
	at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure.validate(ResponseSpecificationImpl.groovy:512)
	at io.restassured.internal.ResponseSpecificationImpl$HamcrestAssertionClosure$validate$1.call(Unknown Source)
	at io.restassured.internal.ResponseSpecificationImpl.validateResponseIfRequired(ResponseSpecificationImpl.groovy:696)
	at io.restassured.internal.ResponseSpecificationImpl.this$2$validateResponseIfRequired(ResponseSpecificationImpl.groovy)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:198)
	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:62)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
	at io.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:135)
	at io.restassured.specification.ResponseSpecification$statusCode$1.callCurrent(Unknown Source)
	at io.restassured.internal.ResponseSpecificationImpl.statusCode(ResponseSpecificationImpl.groovy:143)
	at io.restassured.internal.ValidatableResponseOptionsImpl.statusCode(ValidatableResponseOptionsImpl.java:89)
	at com.yas.product.controller.ProductControllerIT.test_getProductFeature_shouldReturnEmptyList(ProductControllerIT.java:223)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
.body("productList", hasSize(2))
.body("productList", hasSize(0))
.log().ifValidationFails();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ class ProductServiceIT {

@BeforeEach
void setUp() {
generateTestData();
noFileMediaVm = new NoFileMediaVm(1L, "caption", "fileName", "mediaType", "url");
when(mediaService.getMedia(1L)).thenReturn(noFileMediaVm);
when(inventoryService.getProductIdsAddedWarehouse()).thenReturn(new ArrayList<>());
generateTestData();
when(inventoryService.getProductIdsAddedWarehouse()).thenReturn(products.stream().map(p->p.getId()).toList());
}

private void generateTestData() {
Expand Down

0 comments on commit 17e26f0

Please sign in to comment.