adding and importing accessrights.jdl with spotless
This commit is contained in:
@ -53,8 +53,8 @@ public class CustomerResourceIntTest {
|
||||
private static final Integer DEFAULT_REFERENCE = 10000;
|
||||
private static final Integer UPDATED_REFERENCE = 10001;
|
||||
|
||||
private static final String DEFAULT_PREFIX = "z4x";
|
||||
private static final String UPDATED_PREFIX = "js";
|
||||
private static final String DEFAULT_PREFIX = "xfl";
|
||||
private static final String UPDATED_PREFIX = "x0";
|
||||
|
||||
private static final String DEFAULT_NAME = "AAAAAAAAAA";
|
||||
private static final String UPDATED_NAME = "BBBBBBBBBB";
|
||||
|
@ -0,0 +1,594 @@
|
||||
// Licensed under Apache-2.0
|
||||
package org.hostsharing.hsadminng.web.rest;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.hostsharing.hsadminng.HsadminNgApp;
|
||||
import org.hostsharing.hsadminng.domain.User;
|
||||
import org.hostsharing.hsadminng.domain.UserRoleAssignment;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.UserRole;
|
||||
import org.hostsharing.hsadminng.repository.UserRoleAssignmentRepository;
|
||||
import org.hostsharing.hsadminng.service.UserRoleAssignmentQueryService;
|
||||
import org.hostsharing.hsadminng.service.UserRoleAssignmentService;
|
||||
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
/**
|
||||
* Test class for the UserRoleAssignmentResource REST controller.
|
||||
*
|
||||
* @see UserRoleAssignmentResource
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = HsadminNgApp.class)
|
||||
public class UserRoleAssignmentResourceIntTest {
|
||||
|
||||
private static final String DEFAULT_ENTITY_TYPE_ID = "AAAAAAAAAA";
|
||||
private static final String UPDATED_ENTITY_TYPE_ID = "BBBBBBBBBB";
|
||||
|
||||
private static final Long DEFAULT_ENTITY_OBJECT_ID = 1L;
|
||||
private static final Long UPDATED_ENTITY_OBJECT_ID = 2L;
|
||||
|
||||
private static final Long DEFAULT_USER_ID = 1L;
|
||||
private static final Long UPDATED_USER_ID = 2L;
|
||||
|
||||
private static final UserRole DEFAULT_ASSIGNED_ROLE = UserRole.HOSTMASTER;
|
||||
private static final UserRole UPDATED_ASSIGNED_ROLE = UserRole.ADMIN;
|
||||
|
||||
@Autowired
|
||||
private UserRoleAssignmentRepository userRoleAssignmentRepository;
|
||||
|
||||
@Autowired
|
||||
private UserRoleAssignmentService userRoleAssignmentService;
|
||||
|
||||
@Autowired
|
||||
private UserRoleAssignmentQueryService userRoleAssignmentQueryService;
|
||||
|
||||
@Autowired
|
||||
private MappingJackson2HttpMessageConverter jacksonMessageConverter;
|
||||
|
||||
@Autowired
|
||||
private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
|
||||
|
||||
@Autowired
|
||||
private ExceptionTranslator exceptionTranslator;
|
||||
|
||||
@Autowired
|
||||
private EntityManager em;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
private MockMvc restUserRoleAssignmentMockMvc;
|
||||
|
||||
private UserRoleAssignment userRoleAssignment;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
final UserRoleAssignmentResource userRoleAssignmentResource = new UserRoleAssignmentResource(
|
||||
userRoleAssignmentService,
|
||||
userRoleAssignmentQueryService);
|
||||
this.restUserRoleAssignmentMockMvc = MockMvcBuilders.standaloneSetup(userRoleAssignmentResource)
|
||||
.setCustomArgumentResolvers(pageableArgumentResolver)
|
||||
.setControllerAdvice(exceptionTranslator)
|
||||
.setConversionService(createFormattingConversionService())
|
||||
.setMessageConverters(jacksonMessageConverter)
|
||||
.setValidator(validator)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an entity for this test.
|
||||
*
|
||||
* This is a static method, as tests for other entities might also need it,
|
||||
* if they test an entity which requires the current entity.
|
||||
*/
|
||||
public static UserRoleAssignment createEntity(EntityManager em) {
|
||||
UserRoleAssignment userRoleAssignment = new UserRoleAssignment()
|
||||
.entityTypeId(DEFAULT_ENTITY_TYPE_ID)
|
||||
.entityObjectId(DEFAULT_ENTITY_OBJECT_ID)
|
||||
.userId(DEFAULT_USER_ID)
|
||||
.assignedRole(DEFAULT_ASSIGNED_ROLE);
|
||||
return userRoleAssignment;
|
||||
}
|
||||
|
||||
@Before
|
||||
public void initTest() {
|
||||
userRoleAssignment = createEntity(em);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void createUserRoleAssignment() throws Exception {
|
||||
int databaseSizeBeforeCreate = userRoleAssignmentRepository.findAll().size();
|
||||
|
||||
// Create the UserRoleAssignment
|
||||
restUserRoleAssignmentMockMvc.perform(
|
||||
post("/api/user-role-assignments")
|
||||
.contentType(TestUtil.APPLICATION_JSON_UTF8)
|
||||
.content(TestUtil.convertObjectToJsonBytes(userRoleAssignment)))
|
||||
.andExpect(status().isCreated());
|
||||
|
||||
// Validate the UserRoleAssignment in the database
|
||||
List<UserRoleAssignment> userRoleAssignmentList = userRoleAssignmentRepository.findAll();
|
||||
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeCreate + 1);
|
||||
UserRoleAssignment testUserRoleAssignment = userRoleAssignmentList.get(userRoleAssignmentList.size() - 1);
|
||||
assertThat(testUserRoleAssignment.getEntityTypeId()).isEqualTo(DEFAULT_ENTITY_TYPE_ID);
|
||||
assertThat(testUserRoleAssignment.getEntityObjectId()).isEqualTo(DEFAULT_ENTITY_OBJECT_ID);
|
||||
assertThat(testUserRoleAssignment.getUserId()).isEqualTo(DEFAULT_USER_ID);
|
||||
assertThat(testUserRoleAssignment.getAssignedRole()).isEqualTo(DEFAULT_ASSIGNED_ROLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void createUserRoleAssignmentWithExistingId() throws Exception {
|
||||
int databaseSizeBeforeCreate = userRoleAssignmentRepository.findAll().size();
|
||||
|
||||
// Create the UserRoleAssignment with an existing ID
|
||||
userRoleAssignment.setId(1L);
|
||||
|
||||
// An entity with an existing ID cannot be created, so this API call must fail
|
||||
restUserRoleAssignmentMockMvc.perform(
|
||||
post("/api/user-role-assignments")
|
||||
.contentType(TestUtil.APPLICATION_JSON_UTF8)
|
||||
.content(TestUtil.convertObjectToJsonBytes(userRoleAssignment)))
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
// Validate the UserRoleAssignment in the database
|
||||
List<UserRoleAssignment> userRoleAssignmentList = userRoleAssignmentRepository.findAll();
|
||||
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeCreate);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void checkUserIdIsRequired() throws Exception {
|
||||
int databaseSizeBeforeTest = userRoleAssignmentRepository.findAll().size();
|
||||
// set the field null
|
||||
userRoleAssignment.setUserId(null);
|
||||
|
||||
// Create the UserRoleAssignment, which fails.
|
||||
|
||||
restUserRoleAssignmentMockMvc.perform(
|
||||
post("/api/user-role-assignments")
|
||||
.contentType(TestUtil.APPLICATION_JSON_UTF8)
|
||||
.content(TestUtil.convertObjectToJsonBytes(userRoleAssignment)))
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
List<UserRoleAssignment> userRoleAssignmentList = userRoleAssignmentRepository.findAll();
|
||||
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeTest);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void checkAssignedRoleIsRequired() throws Exception {
|
||||
int databaseSizeBeforeTest = userRoleAssignmentRepository.findAll().size();
|
||||
// set the field null
|
||||
userRoleAssignment.setAssignedRole(null);
|
||||
|
||||
// Create the UserRoleAssignment, which fails.
|
||||
|
||||
restUserRoleAssignmentMockMvc.perform(
|
||||
post("/api/user-role-assignments")
|
||||
.contentType(TestUtil.APPLICATION_JSON_UTF8)
|
||||
.content(TestUtil.convertObjectToJsonBytes(userRoleAssignment)))
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
List<UserRoleAssignment> userRoleAssignmentList = userRoleAssignmentRepository.findAll();
|
||||
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeTest);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignments() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList
|
||||
restUserRoleAssignmentMockMvc.perform(get("/api/user-role-assignments?sort=id,desc"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.[*].id").value(hasItem(userRoleAssignment.getId().intValue())))
|
||||
.andExpect(jsonPath("$.[*].entityTypeId").value(hasItem(DEFAULT_ENTITY_TYPE_ID.toString())))
|
||||
.andExpect(jsonPath("$.[*].entityObjectId").value(hasItem(DEFAULT_ENTITY_OBJECT_ID.intValue())))
|
||||
.andExpect(jsonPath("$.[*].userId").value(hasItem(DEFAULT_USER_ID.intValue())))
|
||||
.andExpect(jsonPath("$.[*].assignedRole").value(hasItem(DEFAULT_ASSIGNED_ROLE.toString())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getUserRoleAssignment() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get the userRoleAssignment
|
||||
restUserRoleAssignmentMockMvc.perform(get("/api/user-role-assignments/{id}", userRoleAssignment.getId()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.id").value(userRoleAssignment.getId().intValue()))
|
||||
.andExpect(jsonPath("$.entityTypeId").value(DEFAULT_ENTITY_TYPE_ID.toString()))
|
||||
.andExpect(jsonPath("$.entityObjectId").value(DEFAULT_ENTITY_OBJECT_ID.intValue()))
|
||||
.andExpect(jsonPath("$.userId").value(DEFAULT_USER_ID.intValue()))
|
||||
.andExpect(jsonPath("$.assignedRole").value(DEFAULT_ASSIGNED_ROLE.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByEntityTypeIdIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityTypeId equals to DEFAULT_ENTITY_TYPE_ID
|
||||
defaultUserRoleAssignmentShouldBeFound("entityTypeId.equals=" + DEFAULT_ENTITY_TYPE_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityTypeId equals to UPDATED_ENTITY_TYPE_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("entityTypeId.equals=" + UPDATED_ENTITY_TYPE_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByEntityTypeIdIsInShouldWork() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityTypeId in DEFAULT_ENTITY_TYPE_ID or UPDATED_ENTITY_TYPE_ID
|
||||
defaultUserRoleAssignmentShouldBeFound("entityTypeId.in=" + DEFAULT_ENTITY_TYPE_ID + "," + UPDATED_ENTITY_TYPE_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityTypeId equals to UPDATED_ENTITY_TYPE_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("entityTypeId.in=" + UPDATED_ENTITY_TYPE_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByEntityTypeIdIsNullOrNotNull() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityTypeId is not null
|
||||
defaultUserRoleAssignmentShouldBeFound("entityTypeId.specified=true");
|
||||
|
||||
// Get all the userRoleAssignmentList where entityTypeId is null
|
||||
defaultUserRoleAssignmentShouldNotBeFound("entityTypeId.specified=false");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByEntityObjectIdIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId equals to DEFAULT_ENTITY_OBJECT_ID
|
||||
defaultUserRoleAssignmentShouldBeFound("entityObjectId.equals=" + DEFAULT_ENTITY_OBJECT_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId equals to UPDATED_ENTITY_OBJECT_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("entityObjectId.equals=" + UPDATED_ENTITY_OBJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByEntityObjectIdIsInShouldWork() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId in DEFAULT_ENTITY_OBJECT_ID or UPDATED_ENTITY_OBJECT_ID
|
||||
defaultUserRoleAssignmentShouldBeFound(
|
||||
"entityObjectId.in=" + DEFAULT_ENTITY_OBJECT_ID + "," + UPDATED_ENTITY_OBJECT_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId equals to UPDATED_ENTITY_OBJECT_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("entityObjectId.in=" + UPDATED_ENTITY_OBJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByEntityObjectIdIsNullOrNotNull() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId is not null
|
||||
defaultUserRoleAssignmentShouldBeFound("entityObjectId.specified=true");
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId is null
|
||||
defaultUserRoleAssignmentShouldNotBeFound("entityObjectId.specified=false");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByEntityObjectIdIsGreaterThanOrEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId greater than or equals to DEFAULT_ENTITY_OBJECT_ID
|
||||
defaultUserRoleAssignmentShouldBeFound("entityObjectId.greaterOrEqualThan=" + DEFAULT_ENTITY_OBJECT_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId greater than or equals to UPDATED_ENTITY_OBJECT_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("entityObjectId.greaterOrEqualThan=" + UPDATED_ENTITY_OBJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByEntityObjectIdIsLessThanSomething() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId less than or equals to DEFAULT_ENTITY_OBJECT_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("entityObjectId.lessThan=" + DEFAULT_ENTITY_OBJECT_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where entityObjectId less than or equals to UPDATED_ENTITY_OBJECT_ID
|
||||
defaultUserRoleAssignmentShouldBeFound("entityObjectId.lessThan=" + UPDATED_ENTITY_OBJECT_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByUserIdIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where userId equals to DEFAULT_USER_ID
|
||||
defaultUserRoleAssignmentShouldBeFound("userId.equals=" + DEFAULT_USER_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where userId equals to UPDATED_USER_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("userId.equals=" + UPDATED_USER_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByUserIdIsInShouldWork() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where userId in DEFAULT_USER_ID or UPDATED_USER_ID
|
||||
defaultUserRoleAssignmentShouldBeFound("userId.in=" + DEFAULT_USER_ID + "," + UPDATED_USER_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where userId equals to UPDATED_USER_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("userId.in=" + UPDATED_USER_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByUserIdIsNullOrNotNull() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where userId is not null
|
||||
defaultUserRoleAssignmentShouldBeFound("userId.specified=true");
|
||||
|
||||
// Get all the userRoleAssignmentList where userId is null
|
||||
defaultUserRoleAssignmentShouldNotBeFound("userId.specified=false");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByUserIdIsGreaterThanOrEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where userId greater than or equals to DEFAULT_USER_ID
|
||||
defaultUserRoleAssignmentShouldBeFound("userId.greaterOrEqualThan=" + DEFAULT_USER_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where userId greater than or equals to UPDATED_USER_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("userId.greaterOrEqualThan=" + UPDATED_USER_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByUserIdIsLessThanSomething() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where userId less than or equals to DEFAULT_USER_ID
|
||||
defaultUserRoleAssignmentShouldNotBeFound("userId.lessThan=" + DEFAULT_USER_ID);
|
||||
|
||||
// Get all the userRoleAssignmentList where userId less than or equals to UPDATED_USER_ID
|
||||
defaultUserRoleAssignmentShouldBeFound("userId.lessThan=" + UPDATED_USER_ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByAssignedRoleIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where assignedRole equals to DEFAULT_ASSIGNED_ROLE
|
||||
defaultUserRoleAssignmentShouldBeFound("assignedRole.equals=" + DEFAULT_ASSIGNED_ROLE);
|
||||
|
||||
// Get all the userRoleAssignmentList where assignedRole equals to UPDATED_ASSIGNED_ROLE
|
||||
defaultUserRoleAssignmentShouldNotBeFound("assignedRole.equals=" + UPDATED_ASSIGNED_ROLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByAssignedRoleIsInShouldWork() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where assignedRole in DEFAULT_ASSIGNED_ROLE or UPDATED_ASSIGNED_ROLE
|
||||
defaultUserRoleAssignmentShouldBeFound("assignedRole.in=" + DEFAULT_ASSIGNED_ROLE + "," + UPDATED_ASSIGNED_ROLE);
|
||||
|
||||
// Get all the userRoleAssignmentList where assignedRole equals to UPDATED_ASSIGNED_ROLE
|
||||
defaultUserRoleAssignmentShouldNotBeFound("assignedRole.in=" + UPDATED_ASSIGNED_ROLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByAssignedRoleIsNullOrNotNull() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
|
||||
// Get all the userRoleAssignmentList where assignedRole is not null
|
||||
defaultUserRoleAssignmentShouldBeFound("assignedRole.specified=true");
|
||||
|
||||
// Get all the userRoleAssignmentList where assignedRole is null
|
||||
defaultUserRoleAssignmentShouldNotBeFound("assignedRole.specified=false");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getAllUserRoleAssignmentsByUserIsEqualToSomething() throws Exception {
|
||||
// Initialize the database
|
||||
User user = UserResourceIntTest.createEntity(em);
|
||||
em.persist(user);
|
||||
em.flush();
|
||||
userRoleAssignment.setUser(user);
|
||||
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
|
||||
Long userId = user.getId();
|
||||
|
||||
// Get all the userRoleAssignmentList where user equals to userId
|
||||
defaultUserRoleAssignmentShouldBeFound("userId.equals=" + userId);
|
||||
|
||||
// Get all the userRoleAssignmentList where user equals to userId + 1
|
||||
defaultUserRoleAssignmentShouldNotBeFound("userId.equals=" + (userId + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the search, and checks that the default entity is returned
|
||||
*/
|
||||
private void defaultUserRoleAssignmentShouldBeFound(String filter) throws Exception {
|
||||
restUserRoleAssignmentMockMvc.perform(get("/api/user-role-assignments?sort=id,desc&" + filter))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$.[*].id").value(hasItem(userRoleAssignment.getId().intValue())))
|
||||
.andExpect(jsonPath("$.[*].entityTypeId").value(hasItem(DEFAULT_ENTITY_TYPE_ID)))
|
||||
.andExpect(jsonPath("$.[*].entityObjectId").value(hasItem(DEFAULT_ENTITY_OBJECT_ID.intValue())))
|
||||
.andExpect(jsonPath("$.[*].userId").value(hasItem(DEFAULT_USER_ID.intValue())))
|
||||
.andExpect(jsonPath("$.[*].assignedRole").value(hasItem(DEFAULT_ASSIGNED_ROLE.toString())));
|
||||
|
||||
// Check, that the count call also returns 1
|
||||
restUserRoleAssignmentMockMvc.perform(get("/api/user-role-assignments/count?sort=id,desc&" + filter))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(content().string("1"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the search, and checks that the default entity is not returned
|
||||
*/
|
||||
private void defaultUserRoleAssignmentShouldNotBeFound(String filter) throws Exception {
|
||||
restUserRoleAssignmentMockMvc.perform(get("/api/user-role-assignments?sort=id,desc&" + filter))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(jsonPath("$").isArray())
|
||||
.andExpect(jsonPath("$").isEmpty());
|
||||
|
||||
// Check, that the count call also returns 0
|
||||
restUserRoleAssignmentMockMvc.perform(get("/api/user-role-assignments/count?sort=id,desc&" + filter))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||
.andExpect(content().string("0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void getNonExistingUserRoleAssignment() throws Exception {
|
||||
// Get the userRoleAssignment
|
||||
restUserRoleAssignmentMockMvc.perform(get("/api/user-role-assignments/{id}", Long.MAX_VALUE))
|
||||
.andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void updateUserRoleAssignment() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentService.save(userRoleAssignment);
|
||||
|
||||
int databaseSizeBeforeUpdate = userRoleAssignmentRepository.findAll().size();
|
||||
|
||||
// Update the userRoleAssignment
|
||||
UserRoleAssignment updatedUserRoleAssignment = userRoleAssignmentRepository.findById(userRoleAssignment.getId()).get();
|
||||
// Disconnect from session so that the updates on updatedUserRoleAssignment are not directly saved in db
|
||||
em.detach(updatedUserRoleAssignment);
|
||||
updatedUserRoleAssignment
|
||||
.entityTypeId(UPDATED_ENTITY_TYPE_ID)
|
||||
.entityObjectId(UPDATED_ENTITY_OBJECT_ID)
|
||||
.userId(UPDATED_USER_ID)
|
||||
.assignedRole(UPDATED_ASSIGNED_ROLE);
|
||||
|
||||
restUserRoleAssignmentMockMvc.perform(
|
||||
put("/api/user-role-assignments")
|
||||
.contentType(TestUtil.APPLICATION_JSON_UTF8)
|
||||
.content(TestUtil.convertObjectToJsonBytes(updatedUserRoleAssignment)))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
// Validate the UserRoleAssignment in the database
|
||||
List<UserRoleAssignment> userRoleAssignmentList = userRoleAssignmentRepository.findAll();
|
||||
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeUpdate);
|
||||
UserRoleAssignment testUserRoleAssignment = userRoleAssignmentList.get(userRoleAssignmentList.size() - 1);
|
||||
assertThat(testUserRoleAssignment.getEntityTypeId()).isEqualTo(UPDATED_ENTITY_TYPE_ID);
|
||||
assertThat(testUserRoleAssignment.getEntityObjectId()).isEqualTo(UPDATED_ENTITY_OBJECT_ID);
|
||||
assertThat(testUserRoleAssignment.getUserId()).isEqualTo(UPDATED_USER_ID);
|
||||
assertThat(testUserRoleAssignment.getAssignedRole()).isEqualTo(UPDATED_ASSIGNED_ROLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void updateNonExistingUserRoleAssignment() throws Exception {
|
||||
int databaseSizeBeforeUpdate = userRoleAssignmentRepository.findAll().size();
|
||||
|
||||
// Create the UserRoleAssignment
|
||||
|
||||
// If the entity doesn't have an ID, it will throw BadRequestAlertException
|
||||
restUserRoleAssignmentMockMvc.perform(
|
||||
put("/api/user-role-assignments")
|
||||
.contentType(TestUtil.APPLICATION_JSON_UTF8)
|
||||
.content(TestUtil.convertObjectToJsonBytes(userRoleAssignment)))
|
||||
.andExpect(status().isBadRequest());
|
||||
|
||||
// Validate the UserRoleAssignment in the database
|
||||
List<UserRoleAssignment> userRoleAssignmentList = userRoleAssignmentRepository.findAll();
|
||||
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeUpdate);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void deleteUserRoleAssignment() throws Exception {
|
||||
// Initialize the database
|
||||
userRoleAssignmentService.save(userRoleAssignment);
|
||||
|
||||
int databaseSizeBeforeDelete = userRoleAssignmentRepository.findAll().size();
|
||||
|
||||
// Delete the userRoleAssignment
|
||||
restUserRoleAssignmentMockMvc.perform(
|
||||
delete("/api/user-role-assignments/{id}", userRoleAssignment.getId())
|
||||
.accept(TestUtil.APPLICATION_JSON_UTF8))
|
||||
.andExpect(status().isOk());
|
||||
|
||||
// Validate the database is empty
|
||||
List<UserRoleAssignment> userRoleAssignmentList = userRoleAssignmentRepository.findAll();
|
||||
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeDelete - 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
public void equalsVerifier() throws Exception {
|
||||
TestUtil.equalsVerifier(UserRoleAssignment.class);
|
||||
UserRoleAssignment userRoleAssignment1 = new UserRoleAssignment();
|
||||
userRoleAssignment1.setId(1L);
|
||||
UserRoleAssignment userRoleAssignment2 = new UserRoleAssignment();
|
||||
userRoleAssignment2.setId(userRoleAssignment1.getId());
|
||||
assertThat(userRoleAssignment1).isEqualTo(userRoleAssignment2);
|
||||
userRoleAssignment2.setId(2L);
|
||||
assertThat(userRoleAssignment1).isNotEqualTo(userRoleAssignment2);
|
||||
userRoleAssignment1.setId(null);
|
||||
assertThat(userRoleAssignment1).isNotEqualTo(userRoleAssignment2);
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/* tslint:disable max-line-length */
|
||||
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { JhiEventManager } from 'ng-jhipster';
|
||||
|
||||
import { HsadminNgTestModule } from '../../../test.module';
|
||||
import { UserRoleAssignmentDeleteDialogComponent } from 'app/entities/user-role-assignment/user-role-assignment-delete-dialog.component';
|
||||
import { UserRoleAssignmentService } from 'app/entities/user-role-assignment/user-role-assignment.service';
|
||||
|
||||
describe('Component Tests', () => {
|
||||
describe('UserRoleAssignment Management Delete Component', () => {
|
||||
let comp: UserRoleAssignmentDeleteDialogComponent;
|
||||
let fixture: ComponentFixture<UserRoleAssignmentDeleteDialogComponent>;
|
||||
let service: UserRoleAssignmentService;
|
||||
let mockEventManager: any;
|
||||
let mockActiveModal: any;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HsadminNgTestModule],
|
||||
declarations: [UserRoleAssignmentDeleteDialogComponent]
|
||||
})
|
||||
.overrideTemplate(UserRoleAssignmentDeleteDialogComponent, '')
|
||||
.compileComponents();
|
||||
fixture = TestBed.createComponent(UserRoleAssignmentDeleteDialogComponent);
|
||||
comp = fixture.componentInstance;
|
||||
service = fixture.debugElement.injector.get(UserRoleAssignmentService);
|
||||
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
|
||||
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
|
||||
});
|
||||
|
||||
describe('confirmDelete', () => {
|
||||
it('Should call delete service on confirmDelete', inject(
|
||||
[],
|
||||
fakeAsync(() => {
|
||||
// GIVEN
|
||||
spyOn(service, 'delete').and.returnValue(of({}));
|
||||
|
||||
// WHEN
|
||||
comp.confirmDelete(123);
|
||||
tick();
|
||||
|
||||
// THEN
|
||||
expect(service.delete).toHaveBeenCalledWith(123);
|
||||
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
|
||||
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
|
||||
})
|
||||
));
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,40 @@
|
||||
/* tslint:disable max-line-length */
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { of } from 'rxjs';
|
||||
|
||||
import { HsadminNgTestModule } from '../../../test.module';
|
||||
import { UserRoleAssignmentDetailComponent } from 'app/entities/user-role-assignment/user-role-assignment-detail.component';
|
||||
import { UserRoleAssignment } from 'app/shared/model/user-role-assignment.model';
|
||||
|
||||
describe('Component Tests', () => {
|
||||
describe('UserRoleAssignment Management Detail Component', () => {
|
||||
let comp: UserRoleAssignmentDetailComponent;
|
||||
let fixture: ComponentFixture<UserRoleAssignmentDetailComponent>;
|
||||
const route = ({ data: of({ userRoleAssignment: new UserRoleAssignment(123) }) } as any) as ActivatedRoute;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HsadminNgTestModule],
|
||||
declarations: [UserRoleAssignmentDetailComponent],
|
||||
providers: [{ provide: ActivatedRoute, useValue: route }]
|
||||
})
|
||||
.overrideTemplate(UserRoleAssignmentDetailComponent, '')
|
||||
.compileComponents();
|
||||
fixture = TestBed.createComponent(UserRoleAssignmentDetailComponent);
|
||||
comp = fixture.componentInstance;
|
||||
});
|
||||
|
||||
describe('OnInit', () => {
|
||||
it('Should call load all on init', () => {
|
||||
// GIVEN
|
||||
|
||||
// WHEN
|
||||
comp.ngOnInit();
|
||||
|
||||
// THEN
|
||||
expect(comp.userRoleAssignment).toEqual(jasmine.objectContaining({ id: 123 }));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,60 @@
|
||||
/* tslint:disable max-line-length */
|
||||
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
import { HttpResponse } from '@angular/common/http';
|
||||
import { Observable, of } from 'rxjs';
|
||||
|
||||
import { HsadminNgTestModule } from '../../../test.module';
|
||||
import { UserRoleAssignmentUpdateComponent } from 'app/entities/user-role-assignment/user-role-assignment-update.component';
|
||||
import { UserRoleAssignmentService } from 'app/entities/user-role-assignment/user-role-assignment.service';
|
||||
import { UserRoleAssignment } from 'app/shared/model/user-role-assignment.model';
|
||||
|
||||
describe('Component Tests', () => {
|
||||
describe('UserRoleAssignment Management Update Component', () => {
|
||||
let comp: UserRoleAssignmentUpdateComponent;
|
||||
let fixture: ComponentFixture<UserRoleAssignmentUpdateComponent>;
|
||||
let service: UserRoleAssignmentService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HsadminNgTestModule],
|
||||
declarations: [UserRoleAssignmentUpdateComponent]
|
||||
})
|
||||
.overrideTemplate(UserRoleAssignmentUpdateComponent, '')
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(UserRoleAssignmentUpdateComponent);
|
||||
comp = fixture.componentInstance;
|
||||
service = fixture.debugElement.injector.get(UserRoleAssignmentService);
|
||||
});
|
||||
|
||||
describe('save', () => {
|
||||
it('Should call update service on save for existing entity', fakeAsync(() => {
|
||||
// GIVEN
|
||||
const entity = new UserRoleAssignment(123);
|
||||
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
|
||||
comp.userRoleAssignment = entity;
|
||||
// WHEN
|
||||
comp.save();
|
||||
tick(); // simulate async
|
||||
|
||||
// THEN
|
||||
expect(service.update).toHaveBeenCalledWith(entity);
|
||||
expect(comp.isSaving).toEqual(false);
|
||||
}));
|
||||
|
||||
it('Should call create service on save for new entity', fakeAsync(() => {
|
||||
// GIVEN
|
||||
const entity = new UserRoleAssignment();
|
||||
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
|
||||
comp.userRoleAssignment = entity;
|
||||
// WHEN
|
||||
comp.save();
|
||||
tick(); // simulate async
|
||||
|
||||
// THEN
|
||||
expect(service.create).toHaveBeenCalledWith(entity);
|
||||
expect(comp.isSaving).toEqual(false);
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,128 @@
|
||||
/* tslint:disable max-line-length */
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||
import { ActivatedRoute, Data } from '@angular/router';
|
||||
|
||||
import { HsadminNgTestModule } from '../../../test.module';
|
||||
import { UserRoleAssignmentComponent } from 'app/entities/user-role-assignment/user-role-assignment.component';
|
||||
import { UserRoleAssignmentService } from 'app/entities/user-role-assignment/user-role-assignment.service';
|
||||
import { UserRoleAssignment } from 'app/shared/model/user-role-assignment.model';
|
||||
|
||||
describe('Component Tests', () => {
|
||||
describe('UserRoleAssignment Management Component', () => {
|
||||
let comp: UserRoleAssignmentComponent;
|
||||
let fixture: ComponentFixture<UserRoleAssignmentComponent>;
|
||||
let service: UserRoleAssignmentService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HsadminNgTestModule],
|
||||
declarations: [UserRoleAssignmentComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: ActivatedRoute,
|
||||
useValue: {
|
||||
data: {
|
||||
subscribe: (fn: (value: Data) => void) =>
|
||||
fn({
|
||||
pagingParams: {
|
||||
predicate: 'id',
|
||||
reverse: false,
|
||||
page: 0
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
.overrideTemplate(UserRoleAssignmentComponent, '')
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(UserRoleAssignmentComponent);
|
||||
comp = fixture.componentInstance;
|
||||
service = fixture.debugElement.injector.get(UserRoleAssignmentService);
|
||||
});
|
||||
|
||||
it('Should call load all on init', () => {
|
||||
// GIVEN
|
||||
const headers = new HttpHeaders().append('link', 'link;link');
|
||||
spyOn(service, 'query').and.returnValue(
|
||||
of(
|
||||
new HttpResponse({
|
||||
body: [new UserRoleAssignment(123)],
|
||||
headers
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
// WHEN
|
||||
comp.ngOnInit();
|
||||
|
||||
// THEN
|
||||
expect(service.query).toHaveBeenCalled();
|
||||
expect(comp.userRoleAssignments[0]).toEqual(jasmine.objectContaining({ id: 123 }));
|
||||
});
|
||||
|
||||
it('should load a page', () => {
|
||||
// GIVEN
|
||||
const headers = new HttpHeaders().append('link', 'link;link');
|
||||
spyOn(service, 'query').and.returnValue(
|
||||
of(
|
||||
new HttpResponse({
|
||||
body: [new UserRoleAssignment(123)],
|
||||
headers
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
// WHEN
|
||||
comp.loadPage(1);
|
||||
|
||||
// THEN
|
||||
expect(service.query).toHaveBeenCalled();
|
||||
expect(comp.userRoleAssignments[0]).toEqual(jasmine.objectContaining({ id: 123 }));
|
||||
});
|
||||
|
||||
it('should re-initialize the page', () => {
|
||||
// GIVEN
|
||||
const headers = new HttpHeaders().append('link', 'link;link');
|
||||
spyOn(service, 'query').and.returnValue(
|
||||
of(
|
||||
new HttpResponse({
|
||||
body: [new UserRoleAssignment(123)],
|
||||
headers
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
// WHEN
|
||||
comp.loadPage(1);
|
||||
comp.reset();
|
||||
|
||||
// THEN
|
||||
expect(comp.page).toEqual(0);
|
||||
expect(service.query).toHaveBeenCalledTimes(2);
|
||||
expect(comp.userRoleAssignments[0]).toEqual(jasmine.objectContaining({ id: 123 }));
|
||||
});
|
||||
it('should calculate the sort attribute for an id', () => {
|
||||
// WHEN
|
||||
const result = comp.sort();
|
||||
|
||||
// THEN
|
||||
expect(result).toEqual(['id,asc']);
|
||||
});
|
||||
|
||||
it('should calculate the sort attribute for a non-id attribute', () => {
|
||||
// GIVEN
|
||||
comp.predicate = 'name';
|
||||
|
||||
// WHEN
|
||||
const result = comp.sort();
|
||||
|
||||
// THEN
|
||||
expect(result).toEqual(['name,asc', 'id']);
|
||||
});
|
||||
});
|
||||
});
|
@ -0,0 +1,110 @@
|
||||
/* tslint:disable max-line-length */
|
||||
import { TestBed, getTestBed } from '@angular/core/testing';
|
||||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
|
||||
import { HttpClient, HttpResponse } from '@angular/common/http';
|
||||
import { of } from 'rxjs';
|
||||
import { take, map } from 'rxjs/operators';
|
||||
import { UserRoleAssignmentService } from 'app/entities/user-role-assignment/user-role-assignment.service';
|
||||
import { IUserRoleAssignment, UserRoleAssignment, UserRole } from 'app/shared/model/user-role-assignment.model';
|
||||
|
||||
describe('Service Tests', () => {
|
||||
describe('UserRoleAssignment Service', () => {
|
||||
let injector: TestBed;
|
||||
let service: UserRoleAssignmentService;
|
||||
let httpMock: HttpTestingController;
|
||||
let elemDefault: IUserRoleAssignment;
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [HttpClientTestingModule]
|
||||
});
|
||||
injector = getTestBed();
|
||||
service = injector.get(UserRoleAssignmentService);
|
||||
httpMock = injector.get(HttpTestingController);
|
||||
|
||||
elemDefault = new UserRoleAssignment(0, 'AAAAAAA', 0, 0, UserRole.HOSTMASTER);
|
||||
});
|
||||
|
||||
describe('Service methods', async () => {
|
||||
it('should find an element', async () => {
|
||||
const returnedFromService = Object.assign({}, elemDefault);
|
||||
service
|
||||
.find(123)
|
||||
.pipe(take(1))
|
||||
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
|
||||
|
||||
const req = httpMock.expectOne({ method: 'GET' });
|
||||
req.flush(JSON.stringify(returnedFromService));
|
||||
});
|
||||
|
||||
it('should create a UserRoleAssignment', async () => {
|
||||
const returnedFromService = Object.assign(
|
||||
{
|
||||
id: 0
|
||||
},
|
||||
elemDefault
|
||||
);
|
||||
const expected = Object.assign({}, returnedFromService);
|
||||
service
|
||||
.create(new UserRoleAssignment(null))
|
||||
.pipe(take(1))
|
||||
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
|
||||
const req = httpMock.expectOne({ method: 'POST' });
|
||||
req.flush(JSON.stringify(returnedFromService));
|
||||
});
|
||||
|
||||
it('should update a UserRoleAssignment', async () => {
|
||||
const returnedFromService = Object.assign(
|
||||
{
|
||||
entityTypeId: 'BBBBBB',
|
||||
entityObjectId: 1,
|
||||
userId: 1,
|
||||
assignedRole: 'BBBBBB'
|
||||
},
|
||||
elemDefault
|
||||
);
|
||||
|
||||
const expected = Object.assign({}, returnedFromService);
|
||||
service
|
||||
.update(expected)
|
||||
.pipe(take(1))
|
||||
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
|
||||
const req = httpMock.expectOne({ method: 'PUT' });
|
||||
req.flush(JSON.stringify(returnedFromService));
|
||||
});
|
||||
|
||||
it('should return a list of UserRoleAssignment', async () => {
|
||||
const returnedFromService = Object.assign(
|
||||
{
|
||||
entityTypeId: 'BBBBBB',
|
||||
entityObjectId: 1,
|
||||
userId: 1,
|
||||
assignedRole: 'BBBBBB'
|
||||
},
|
||||
elemDefault
|
||||
);
|
||||
const expected = Object.assign({}, returnedFromService);
|
||||
service
|
||||
.query(expected)
|
||||
.pipe(
|
||||
take(1),
|
||||
map(resp => resp.body)
|
||||
)
|
||||
.subscribe(body => expect(body).toContainEqual(expected));
|
||||
const req = httpMock.expectOne({ method: 'GET' });
|
||||
req.flush(JSON.stringify([returnedFromService]));
|
||||
httpMock.verify();
|
||||
});
|
||||
|
||||
it('should delete a UserRoleAssignment', async () => {
|
||||
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
|
||||
|
||||
const req = httpMock.expectOne({ method: 'DELETE' });
|
||||
req.flush({ status: 200 });
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
httpMock.verify();
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user