Skip to content

Commit

Permalink
OAM-218: Added extra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sradziszewski committed Jun 25, 2024
1 parent 63578c4 commit 06281ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

package org.openlmis.stockmanagement.repository;

import static org.openlmis.stockmanagement.web.ValidSourceDestinationSearchParams.PROGRAM_ID;

import java.util.List;
import java.util.Set;
import java.util.UUID;
Expand All @@ -28,7 +30,6 @@
public interface SourceDestinationAssignmentRepository<T extends SourceDestinationAssignment>
extends JpaRepository<T, UUID> {

String PROGRAM_ID = "programId";
String FACILITY_TYPE_ID = "facilityTypeId";
String NODE_ID = "nodeId";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.openlmis.stockmanagement.web;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.openlmis.stockmanagement.web.ValidReasonAssignmentSearchParams.FACILITY_TYPE;
Expand All @@ -39,10 +40,13 @@ public class ValidReasonAssignmentSearchParamsTest {
@Test
public void shouldGetProgramIdValueFromParameters() {
LinkedMultiValueMap<String, String> queryMap = new LinkedMultiValueMap<>();
final UUID typeId = UUID.randomUUID();
queryMap.add(PROGRAM, VALUE.toString());
queryMap.add(FACILITY_TYPE, typeId.toString());
ValidReasonAssignmentSearchParams params = new ValidReasonAssignmentSearchParams(queryMap);

assertTrue(params.getProgram().contains(VALUE));
assertFalse(params.getProgram().contains(typeId));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.openlmis.stockmanagement.web.ValidSourceDestinationSearchParams.PROGRAM_ID;

import java.util.UUID;
import org.junit.Ignore;
import org.junit.Test;
import org.openlmis.stockmanagement.exception.ValidationMessageException;
import org.springframework.util.LinkedMultiValueMap;
Expand All @@ -43,11 +42,9 @@ public void shouldGetProgramIdValueFromParameters() {
queryMap.add(FACILITY_ID, FACILITY_ID_VALUE.toString());
ValidSourceDestinationSearchParams params = new ValidSourceDestinationSearchParams(queryMap);

//assertEquals(PROGRAM_ID_VALUE, params.getProgramId());
assertTrue(params.getProgramId().contains(PROGRAM_ID_VALUE));
}

@Ignore
@Test
public void shouldAssignNullIfProgramIdIsAbsentInParameters() {
ValidSourceDestinationSearchParams params =
Expand All @@ -56,6 +53,16 @@ public void shouldAssignNullIfProgramIdIsAbsentInParameters() {
assertNull(params.getProgramId());
}

@Test
public void shouldAssignNullIfProgramIdIsNullInParameters() {
LinkedMultiValueMap<String, String> queryMap = new LinkedMultiValueMap<>();
queryMap.add(PROGRAM_ID, null);
queryMap.add(FACILITY_ID, FACILITY_ID_VALUE.toString());
ValidSourceDestinationSearchParams params = new ValidSourceDestinationSearchParams(queryMap);

assertNull(params.getProgramId());
}

@Test
public void shouldGetFacilityIdValueFromParameters() {
LinkedMultiValueMap<String, String> queryMap = new LinkedMultiValueMap<>();
Expand Down

0 comments on commit 06281ac

Please sign in to comment.