Skip to content
Snippets Groups Projects
Commit cc91afec authored by Anders Montsko Austlid's avatar Anders Montsko Austlid
Browse files

Merge branch 'feature/achievmentrepository-tests' into 'main'

Added AchievementRepository tests

Closes #177

See merge request idatt2106-v23-03/backend!135
parents 377db584 625a6354
No related branches found
No related tags found
No related merge requests found
package ntnu.idatt2016.v233.SmartMat.repository.user;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.util.Optional;
import ntnu.idatt2016.v233.SmartMat.entity.group.Achievement;
import ntnu.idatt2016.v233.SmartMat.repository.user.AchievementRepository;
import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(SpringExtension.class)
@DataJpaTest
class AchievementRepositoryTest {
@Autowired
private AchievementRepository achievementRepository;
private Achievement achievement1;
@BeforeEach
void setUp() {
achievement1 = Achievement.builder()
.achievementName("Eco Warrior")
.achievementDescription("Reduce waste by 50% in one month")
.build();
achievementRepository.save(achievement1);
}
@Test
void findByAchievementName() {
Optional<Achievement> result = achievementRepository.findByAchievementName("Eco Warrior");
assertTrue(result.isPresent());
assertEquals(achievement1.getAchievementName(), result.get().getAchievementName());
assertEquals(achievement1.getAchievementDescription(), result.get().getAchievementDescription());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment