Exemplo n.º 1
0
  @Test
  @Transactional
  public void updateAluno() throws Exception {
    // Initialize the database
    alunoRepository.saveAndFlush(aluno);

    int databaseSizeBeforeUpdate = alunoRepository.findAll().size();

    // Update the aluno
    aluno.setNome(UPDATED_NOME);
    aluno.setCpf(UPDATED_CPF);
    aluno.setEndereco(UPDATED_ENDERECO);

    restAlunoMockMvc
        .perform(
            put("/api/alunos")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(aluno)))
        .andExpect(status().isOk());

    // Validate the Aluno in the database
    List<Aluno> alunos = alunoRepository.findAll();
    assertThat(alunos).hasSize(databaseSizeBeforeUpdate);
    Aluno testAluno = alunos.get(alunos.size() - 1);
    assertThat(testAluno.getNome()).isEqualTo(UPDATED_NOME);
    assertThat(testAluno.getCpf()).isEqualTo(UPDATED_CPF);
    assertThat(testAluno.getEndereco()).isEqualTo(UPDATED_ENDERECO);
  }
Exemplo n.º 2
0
  @Test
  @Transactional
  public void deleteAluno() throws Exception {
    // Initialize the database
    alunoRepository.saveAndFlush(aluno);

    int databaseSizeBeforeDelete = alunoRepository.findAll().size();

    // Get the aluno
    restAlunoMockMvc
        .perform(delete("/api/alunos/{id}", aluno.getId()).accept(TestUtil.APPLICATION_JSON_UTF8))
        .andExpect(status().isOk());

    // Validate the database is empty
    List<Aluno> alunos = alunoRepository.findAll();
    assertThat(alunos).hasSize(databaseSizeBeforeDelete - 1);
  }
Exemplo n.º 3
0
  @Test
  @Transactional
  public void checkEnderecoIsRequired() throws Exception {
    int databaseSizeBeforeTest = alunoRepository.findAll().size();
    // set the field null
    aluno.setEndereco(null);

    // Create the Aluno, which fails.

    restAlunoMockMvc
        .perform(
            post("/api/alunos")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(aluno)))
        .andExpect(status().isBadRequest());

    List<Aluno> alunos = alunoRepository.findAll();
    assertThat(alunos).hasSize(databaseSizeBeforeTest);
  }
Exemplo n.º 4
0
  @Test
  @Transactional
  public void createAluno() throws Exception {
    int databaseSizeBeforeCreate = alunoRepository.findAll().size();

    // Create the Aluno

    restAlunoMockMvc
        .perform(
            post("/api/alunos")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(aluno)))
        .andExpect(status().isCreated());

    // Validate the Aluno in the database
    List<Aluno> alunos = alunoRepository.findAll();
    assertThat(alunos).hasSize(databaseSizeBeforeCreate + 1);
    Aluno testAluno = alunos.get(alunos.size() - 1);
    assertThat(testAluno.getNome()).isEqualTo(DEFAULT_NOME);
    assertThat(testAluno.getCpf()).isEqualTo(DEFAULT_CPF);
    assertThat(testAluno.getEndereco()).isEqualTo(DEFAULT_ENDERECO);
  }