Skip to content

Commit

Permalink
test: added unit tests for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
empassaro committed Jan 29, 2024
1 parent cec64fa commit 46b22e8
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
import it.pagopa.selfcare.product.entity.ProductRole;
import it.pagopa.selfcare.product.entity.ProductRoleInfo;
import it.pagopa.selfcare.product.service.ProductService;
import it.pagopa.selfcare.user.constant.OnboardedProductState;
import it.pagopa.selfcare.user.entity.OnboardedProduct;
import it.pagopa.selfcare.user.entity.UserInstitution;
import it.pagopa.selfcare.user.exception.InvalidRequestException;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -81,4 +85,25 @@ private Product getProductResource() {
return productResource;
}

@Test
void testFilterProductWorks() {
OnboardedProduct onboardedProduct1 = new OnboardedProduct();
onboardedProduct1.setProductId("test-id");
onboardedProduct1.setStatus(OnboardedProductState.ACTIVE);
OnboardedProduct onboardedProduct2 = new OnboardedProduct();
onboardedProduct2.setProductId("test-id");
onboardedProduct2.setStatus(OnboardedProductState.DELETED);

List<OnboardedProduct> onboardedProducts = new ArrayList<>();
onboardedProducts.add(onboardedProduct1);
onboardedProducts.add(onboardedProduct2);

UserInstitution userInstitution = new UserInstitution();
userInstitution.setProducts(onboardedProducts);

String[] states = {"ACTIVE"};
UserInstitution filteredUserInstitution = userUtils.filterProduct(userInstitution, states);
Assertions.assertEquals(1, filteredUserInstitution.getProducts().size());
}

}

0 comments on commit 46b22e8

Please sign in to comment.