@@ -509,6 +509,39 @@ void getUserCount() throws Exception {
509509 verifyNoMoreInteractions (userServiceMock );
510510 }
511511
512+ @ Test
513+ void getUserCountWithNullRolesAndStatus () throws Exception {
514+ final String institutionId = "institutionId" ;
515+ final String productId = "productId" ;
516+
517+ final UserCount userCount = new UserCount ();
518+ userCount .setInstitutionId (institutionId );
519+ userCount .setProductId (productId );
520+ userCount .setRoles (Arrays .asList ("defaultRole1" , "defaultRole2" ));
521+ userCount .setStatus (Arrays .asList ("defaultStatus1" , "defaultStatus2" ));
522+ userCount .setCount (2L );
523+ when (userServiceMock .getUserCount (institutionId , productId , Collections .emptyList (), Collections .emptyList ())).thenReturn (userCount );
524+
525+ final MvcResult result = mockMvc .perform (MockMvcRequestBuilders
526+ .get (BASE_URL + "/{institutionId}/products/{productId}/users/count" , institutionId , productId )
527+ .contentType (APPLICATION_JSON_VALUE )
528+ .accept (APPLICATION_JSON_VALUE ))
529+ .andExpect (status ().isOk ())
530+ .andReturn ();
531+
532+ UserCountResource resource = objectMapper .readValue (
533+ result .getResponse ().getContentAsString (), new TypeReference <>() {});
534+ assertEquals (userCount .getInstitutionId (), resource .getInstitutionId ());
535+ assertEquals (userCount .getProductId (), resource .getProductId ());
536+ assertIterableEquals (userCount .getRoles (), resource .getRoles ());
537+ assertIterableEquals (userCount .getStatus (), resource .getStatus ());
538+ assertEquals (userCount .getCount (), resource .getCount ());
539+
540+ verify (userServiceMock , times (1 ))
541+ .getUserCount (institutionId , productId , Collections .emptyList (), Collections .emptyList ());
542+ verifyNoMoreInteractions (userServiceMock );
543+ }
544+
512545 private DelegationWithInfo dummyDelegation () {
513546 DelegationWithInfo delegation = new DelegationWithInfo ();
514547 delegation .setInstitutionId ("from" );
0 commit comments