Untitled

mail@pastecode.io avatar
unknown
plain_text
17 days ago
1.5 kB
1
Indexable
Never
package com.tujuhsembilan.app.repository;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.jdbc.EmbeddedDatabaseConnection;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;

import com.tujuhsembilan.app.model.TalentLevel;

import java.util.List;

@DataJpaTest
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.H2)
public class TalentLevelRepositoryTest {

    @Autowired
    private TalentLevelRepository talentLevelRepository;
    
    @Test
    public void getSaveTalentLevel() {
        TalentLevel talentLevel = TalentLevel.builder()
                .talentLevelName("junior")
                .isActive(true).build();
        TalentLevel talentLevel2 = TalentLevel.builder()
            .talentLevelName("Middle")
            .isActive(true).build();
        TalentLevel talentLevel3 = TalentLevel.builder()
            .talentLevelName("Senior")
            .isActive(true).build();

        talentLevelRepository.save(talentLevel);
        talentLevelRepository.save(talentLevel2);
        talentLevelRepository.save(talentLevel3);

        List<TalentLevel> talentLevelList = talentLevelRepository.findAll();

        Assertions.assertThat(talentLevelList).isNotNull();
        Assertions.assertThat(talentLevelList.size()).isEqualTo(3);
    }
}
Leave a Comment