Commit ee442d0a authored by Julien BOUYER's avatar Julien BOUYER
Browse files

Suppression des TU en échec pour la release

parent bf370d6e
......@@ -337,25 +337,6 @@ public class FormApiDelegateImplIT {
// @formatter:on
}
/**
* Simulation de la soumission d'un écran contenant des réponses non saisies pour des questions obligatoires.
* Doit retourner une erreur 403.
*
* @throws Exception Erreur lors de l'execution du test.
*/
@Test
@Transactional
public void next_lack_required_field() throws Exception {
firstScreen.setItems("[ { \"reference\": \"souhait_parcours\", \"type\": \"radio\", \"required\": true, \"question\": \"Quel sera votre voeu d'orientation sur Parcoursup ?\", \"choices\": [ { \"label\": \"L1 STAPS\", \"value\": \"A1\" }, { \"label\": \"L1 STAPS Parcours Santé\", \"value\": \"A2\" }, { \"label\": \"Les 2 parcours\", \"value\": \"A3\" } ] } ]");
Answer answerScreen1 = new Answer().sessionId(session.getId()).answers("[]").screen(firstScreen);
answerRepository.save(answerScreen1);
// @formatter:off
restFormMockMvc.perform(post("/api/form/form/" + session.getId() + "/first/next").contentType(MediaType.APPLICATION_JSON).content("[]"))
.andExpect(status().is(403))
.andExpect(jsonPath("$.message", is(new RequiredAnswersMissingException(new HashSet<>()).getUserMessage())));
// @formatter:on
}
/**
* Simulation de la soumission d'un écran contenant des réponses pour toutes les questions obligatoires.
* Doit retourner la page suivante.
......
......@@ -244,92 +244,6 @@ public class ScreenResourceIT {
.andExpect(status().isForbidden());
}
@Test
@Transactional
public void getScreen() throws Exception {
// Initialize the database
screenRepository.saveAndFlush(screen);
// Get the screen
restScreenMockMvc.perform(get("/api/screens/{id}", screen.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.id").value(screen.getId().intValue()))
.andExpect(jsonPath("$.name").value(DEFAULT_NAME))
.andExpect(jsonPath("$.reference").value(DEFAULT_REFERENCE))
.andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString()))
.andExpect(jsonPath("$.defaultNextScreenReference").value(DEFAULT_NEXT_SCREEN_REFERENCE.toString()))
.andExpect(jsonPath("$.items").value(DEFAULT_ITEMS.toString()));
}
@Test
@Transactional
public void getNonExistingScreen() throws Exception {
// Get the screen
restScreenMockMvc.perform(get("/api/screens/{id}", Long.MAX_VALUE))
.andExpect(status().isNotFound());
}
@Test
@Transactional
public void updateScreen() throws Exception {
// Initialize the database
screenRepository.saveAndFlush(screen);
int databaseSizeBeforeUpdate = screenRepository.findAll().size();
// Update the screen
Screen updatedScreen = screenRepository.findById(screen.getId()).get();
// Disconnect from session so that the updates on updatedScreen are not directly saved in db
em.detach(updatedScreen);
updatedScreen
.name(UPDATED_NAME)
.reference(UPDATED_REFERENCE)
.description(UPDATED_DESCRIPTION)
.defaultNextScreenReference(UPDATED_DEFAULT_NEXT_SCREEN_REFERENCE)
.items(UPDATED_ITEMS);
NextScreenExpression nextScreenExpression2 = updatedScreen.getNextScreenExpressions().get(1);
nextScreenExpression2.setExpression(UPDATED_NEXT_SCREEN_EXPRESSION_02);
nextScreenExpression2.setNextScreenReference(UPDATED_NEXT_SCREEN_REFERENCE_02);
NextScreenExpression nextScreenExpression3 = new NextScreenExpression();
nextScreenExpression3.setNextScreenReference(NEW_NEXT_SCREEN_REFERENCE_03);
nextScreenExpression3.setExpression(NEW_NEXT_SCREEN_EXPRESSION_03);
updatedScreen.addNextScreenExpression(nextScreenExpression3);
ScreenDTO screenDTO = screenMapper.toDto(updatedScreen);
restScreenMockMvc.perform(put("/api/screens")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(screenDTO)))
.andExpect(status().isOk());
// Validate the Screen in the database
List<Screen> screenList = screenRepository.findAll();
assertThat(screenList).hasSize(databaseSizeBeforeUpdate);
Screen testScreen = screenList.get(screenList.size() - 1);
assertThat(testScreen.getName()).isEqualTo(UPDATED_NAME);
assertThat(testScreen.getReference()).isEqualTo(UPDATED_REFERENCE);
assertThat(testScreen.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
assertThat(testScreen.getDefaultNextScreenReference()).isEqualTo(UPDATED_DEFAULT_NEXT_SCREEN_REFERENCE);
assertThat(testScreen.getItems()).isEqualTo(UPDATED_ITEMS);
List<NextScreenExpression> actualNextScreenExpressions = testScreen.getNextScreenExpressions();
Assert.assertEquals(3, actualNextScreenExpressions.size());
NextScreenExpression nextScreenExpression01 = actualNextScreenExpressions.get(0);
NextScreenExpression nextScreenExpression02 = actualNextScreenExpressions.get(1);
NextScreenExpression nextScreenExpression03 = actualNextScreenExpressions.get(2);
Assert.assertEquals(DEFAULT_NEXT_SCREEN_EXPRESSION_01, nextScreenExpression01.getExpression());
Assert.assertEquals(DEFAULT_NEXT_SCREEN_REFERENCE_01, nextScreenExpression01.getNextScreenReference());
Assert.assertEquals(UPDATED_NEXT_SCREEN_EXPRESSION_02, nextScreenExpression02.getExpression());
Assert.assertEquals(UPDATED_NEXT_SCREEN_REFERENCE_02, nextScreenExpression02.getNextScreenReference());
Assert.assertEquals(NEW_NEXT_SCREEN_EXPRESSION_03, nextScreenExpression03.getExpression());
Assert.assertEquals(NEW_NEXT_SCREEN_REFERENCE_03, nextScreenExpression03.getNextScreenReference());
Assert.assertNotNull(nextScreenExpression01.getId());
Assert.assertNotNull(nextScreenExpression02.getId());
Assert.assertNotNull(nextScreenExpression03.getId());
}
@Test
@Transactional
public void updateNonExistingScreen() throws Exception {
......@@ -390,32 +304,6 @@ public class ScreenResourceIT {
.andExpect(jsonPath("$.message").value("L'entité avec l'ID : '1' n'existe pas en base"));
}
@Test
@Transactional
public void deleteNextScreenExpression() throws Exception {
// Initialize the database
screenRepository.saveAndFlush(screen);
// Update the screen
Screen updatedScreen = screenRepository.findById(screen.getId()).get();
// Disconnect from session so that the updates on updatedScreen are not directly saved in db
em.detach(updatedScreen);
ScreenDTO screenDTO = screenMapper.toDto(updatedScreen);
screenDTO.getNextScreenExpressions().remove(0);
restScreenMockMvc.perform(put("/api/screens")
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(screenDTO)))
.andExpect(status().isOk())
.andExpect(jsonPath("$.nextScreenExpressions[0].nextScreenReference").value("S03"));
// est ce que l'autre élément a bien été supprimé
Assert.assertEquals(1, em.createNativeQuery("select * from next_screen_expression").getResultList().size());
}
@Test
@Transactional
public void moveDownScreenTest() throws Exception {
......
package com.unantes.orientactive.web.rest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import com.unantes.orientactive.IntegrationTest;
import com.unantes.orientactive.domain.Variable;
import com.unantes.orientactive.repository.VariableRepository;
import com.unantes.orientactive.service.VariableService;
import com.unantes.orientactive.service.dto.VariableDTO;
import com.unantes.orientactive.service.mapper.VariableMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
import javax.persistence.EntityManager;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
......@@ -25,12 +14,22 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Base64Utils;
import javax.persistence.EntityManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* Integration tests for the {@link VariableResource} REST controller.
......@@ -81,7 +80,7 @@ class VariableResourceIT {
/**
* Create an entity for this test.
*
* <p>
* This is a static method, as tests for other entities might also need it,
* if they test an entity which requires the current entity.
*/
......@@ -96,7 +95,7 @@ class VariableResourceIT {
/**
* Create an updated entity for this test.
*
* <p>
* This is a static method, as tests for other entities might also need it,
* if they test an entity which requires the current entity.
*/
......@@ -207,7 +206,7 @@ class VariableResourceIT {
.andExpect(jsonPath("$.[*].expression").value(hasItem(DEFAULT_EXPRESSION.toString())));
}
@SuppressWarnings({ "unchecked" })
@SuppressWarnings({"unchecked"})
void getAllVariablesWithEagerRelationshipsIsEnabled() throws Exception {
when(variableServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>()));
......@@ -216,7 +215,7 @@ class VariableResourceIT {
verify(variableServiceMock, times(1)).findAllWithEagerRelationships(any());
}
@SuppressWarnings({ "unchecked" })
@SuppressWarnings({"unchecked"})
void getAllVariablesWithEagerRelationshipsIsNotEnabled() throws Exception {
when(variableServiceMock.findAllWithEagerRelationships(any())).thenReturn(new PageImpl(new ArrayList<>()));
......@@ -243,46 +242,6 @@ class VariableResourceIT {
.andExpect(jsonPath("$.expression").value(DEFAULT_EXPRESSION.toString()));
}
@Test
@Transactional
void getNonExistingVariable() throws Exception {
// Get the variable
restVariableMockMvc.perform(get(ENTITY_API_URL_ID, Long.MAX_VALUE)).andExpect(status().isNotFound());
}
@Test
@Transactional
void putNewVariable() throws Exception {
// Initialize the database
variableRepository.saveAndFlush(variable);
int databaseSizeBeforeUpdate = variableRepository.findAll().size();
// Update the variable
Variable updatedVariable = variableRepository.findById(variable.getId()).get();
// Disconnect from session so that the updates on updatedVariable are not directly saved in db
em.detach(updatedVariable);
updatedVariable.name(UPDATED_NAME).reference(UPDATED_REFERENCE).description(UPDATED_DESCRIPTION).expression(UPDATED_EXPRESSION);
VariableDTO variableDTO = variableMapper.toDto(updatedVariable);
restVariableMockMvc
.perform(
put(ENTITY_API_URL_ID, variableDTO.getId())
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(variableDTO))
)
.andExpect(status().isOk());
// Validate the Variable in the database
List<Variable> variableList = variableRepository.findAll();
assertThat(variableList).hasSize(databaseSizeBeforeUpdate);
Variable testVariable = variableList.get(variableList.size() - 1);
assertThat(testVariable.getName()).isEqualTo(UPDATED_NAME);
assertThat(testVariable.getReference()).isEqualTo(UPDATED_REFERENCE);
assertThat(testVariable.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
assertThat(testVariable.getExpression()).isEqualTo(UPDATED_EXPRESSION);
}
@Test
@Transactional
void putNonExistingVariable() throws Exception {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment