Skip to content

Commit 1b6330e

Browse files
committed
added test for bugfix
1 parent 8fddcff commit 1b6330e

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/test/java/com/redhat/labs/omp/mocks/MockGitLabService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public List<Group> getGroupByName(String name) {
6161
groupList.add(Group.builder().id(3).name("customer1").path("customer1").build());
6262
} else if ("project4".equalsIgnoreCase(name)) {
6363
groupList.add(Group.builder().id(4).name("project1").path("project1").build());
64+
} else if ("customer".equalsIgnoreCase(name)) {
65+
groupList.add(Group.builder().id(11).name("customerA").path("customerA").parentId(10).build());
66+
groupList.add(Group.builder().id(12).name("customer").path("customer").parentId(10).build());
6467
}
6568

6669
return groupList;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.redhat.labs.omp.service;
2+
3+
import java.util.Optional;
4+
5+
import javax.inject.Inject;
6+
7+
import org.junit.jupiter.api.Assertions;
8+
import org.junit.jupiter.api.Test;
9+
10+
import com.redhat.labs.omp.models.gitlab.Group;
11+
12+
import io.quarkus.test.junit.QuarkusTest;
13+
14+
@QuarkusTest
15+
public class GroupServiceTest {
16+
17+
@Inject
18+
GroupService groupService;
19+
20+
@Test
21+
public void testGetGitLabGroupByNameNoGroupsExist() {
22+
23+
Optional<Group> optional = groupService.getGitLabGroupByName("customerA", 1);
24+
Assertions.assertFalse(optional.isPresent());
25+
26+
}
27+
28+
@Test
29+
public void testGetGitLabGroupByNameMultipleGroupsExistNoMatch() {
30+
31+
Optional<Group> optional = groupService.getGitLabGroupByName("customer", 1);
32+
Assertions.assertFalse(optional.isPresent());
33+
34+
}
35+
36+
@Test
37+
public void testGetGitLabGroupByNameMultipleGroupsExistMatch() {
38+
39+
Optional<Group> optional = groupService.getGitLabGroupByName("customer", 10);
40+
Assertions.assertTrue(optional.isPresent());
41+
42+
}
43+
44+
}

0 commit comments

Comments
 (0)