Skip to content

Commit 57aac4d

Browse files
committed
additional tests to cover setup in ObjectMapperPostProcessorConfig
1 parent c4c9f38 commit 57aac4d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

service/src/test/java/uk/nhs/adaptors/gp2gp/common/configuration/ObjectMapperPostProcessorConfigTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import org.mockito.InjectMocks;
88
import org.mockito.Mock;
99
import org.mockito.MockitoAnnotations;
10+
import uk.nhs.adaptors.gp2gp.ehr.EhrExtractStatusService;
1011

12+
import static com.mongodb.assertions.Assertions.assertFalse;
13+
import static com.mongodb.assertions.Assertions.assertTrue;
1114
import static org.mockito.ArgumentMatchers.argThat;
1215
import static org.mockito.Mockito.times;
1316
import static org.mockito.Mockito.verify;
@@ -18,6 +21,9 @@ public class ObjectMapperPostProcessorConfigTest {
1821
@Mock
1922
private ObjectMapper objectMapper;
2023

24+
@Mock
25+
private EhrExtractStatusService ehrExtractStatusService;
26+
2127
@Mock
2228
private JsonFactory mockJsonFactory;
2329

@@ -34,9 +40,22 @@ public void objectMapperPostProcessSetsMaxDataProcessingLimitTest() {
3440

3541
when(objectMapper.getFactory()).thenReturn(mockJsonFactory);
3642

37-
objectMapperPostProcessorConfig.postProcessAfterInitialization(objectMapper, "objectMapper");
43+
var objectMapperWithoutDataLimit = objectMapperPostProcessorConfig.postProcessAfterInitialization(objectMapper, "objectMapper");
3844

45+
assertTrue(objectMapperWithoutDataLimit instanceof ObjectMapper);
3946
verify(mockJsonFactory, times(1))
4047
.setStreamReadConstraints(argThat(constraints -> constraints.getMaxStringLength() == Integer.MAX_VALUE));
4148
}
49+
50+
@Test
51+
public void limitInObjectMapperPostProcessSetOnlyForObjectMapperTest() {
52+
53+
var objectMapperWithoutDataLimit
54+
= objectMapperPostProcessorConfig.postProcessAfterInitialization(ehrExtractStatusService, "service");
55+
56+
assertFalse(objectMapperWithoutDataLimit instanceof ObjectMapper);
57+
verify(mockJsonFactory, times(0))
58+
.setStreamReadConstraints(argThat(constraints -> constraints.getMaxStringLength() == Integer.MAX_VALUE));
59+
}
60+
4261
}

0 commit comments

Comments
 (0)