Search in sources :

Example 21 with Developer

use of com.viadee.sonarQuest.entities.Developer in project sonarQuest by viadee.

the class QuestServiceTest method testGetAllQuestsForWorldAndDeveloper.

@Test
public void testGetAllQuestsForWorldAndDeveloper() {
    // create mock developer
    final Developer mockDeveloper = new Developer();
    mockDeveloper.setUsername("mock");
    // create mock world
    final World mockWorld = new World();
    // create mock quests
    final Quest mockQuest1 = new Quest();
    final Quest mockQuest2 = new Quest();
    final Quest mockQuest3 = new Quest();
    mockQuest1.setTitle("mockQuest1");
    mockQuest2.setTitle("mockQuest2");
    mockQuest3.setTitle("mockQuest3");
    mockQuest1.setWorld(mockWorld);
    mockQuest2.setWorld(mockWorld);
    mockQuest3.setWorld(mockWorld);
    final List<Quest> mockQuests = new ArrayList<>();
    mockQuests.add(mockQuest1);
    mockQuests.add(mockQuest2);
    mockQuests.add(mockQuest3);
    // create mock participations
    final Participation mockParticipation1 = new Participation(mockQuest1, mockDeveloper);
    final Participation mockParticipation2 = new Participation(mockQuest2, mockDeveloper);
    final List<Participation> mockParticipations = new ArrayList<>();
    mockParticipations.add(mockParticipation1);
    mockParticipations.add(mockParticipation2);
    // init mock repos
    when(participationRepository.findByDeveloper(mockDeveloper)).thenReturn(mockParticipations);
    when(questRepository.findByWorld(mockWorld)).thenReturn(mockQuests);
    // call method to be tested
    final List<List<Quest>> result = questService.getAllQuestsForWorldAndDeveloper(mockWorld, mockDeveloper);
    // verify result
    assertTrue(result.get(0).contains(mockQuest1));
    assertTrue(result.get(0).contains(mockQuest2));
    assertTrue(result.get(1).contains(mockQuest3));
}
Also used : Participation(com.viadee.sonarQuest.entities.Participation) ArrayList(java.util.ArrayList) Developer(com.viadee.sonarQuest.entities.Developer) ArrayList(java.util.ArrayList) List(java.util.List) World(com.viadee.sonarQuest.entities.World) Quest(com.viadee.sonarQuest.entities.Quest) Test(org.junit.Test)

Aggregations

Developer (com.viadee.sonarQuest.entities.Developer)21 World (com.viadee.sonarQuest.entities.World)7 Adventure (com.viadee.sonarQuest.entities.Adventure)6 Participation (com.viadee.sonarQuest.entities.Participation)5 Quest (com.viadee.sonarQuest.entities.Quest)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 DeveloperDto (com.viadee.sonarQuest.dtos.DeveloperDto)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 SkillType (com.viadee.sonarQuest.constants.SkillType)1 Level (com.viadee.sonarQuest.entities.Level)1 Skill (com.viadee.sonarQuest.entities.Skill)1 Task (com.viadee.sonarQuest.entities.Task)1 DeveloperGratification (com.viadee.sonarQuest.interfaces.DeveloperGratification)1 DeveloperRepository (com.viadee.sonarQuest.repositories.DeveloperRepository)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1