Skip to content

Commit 07947b1

Browse files
authored
Merge pull request #57 from dwasinge/bugfix-groupexists
Get Group By Name Should Validate Against GitLab Group Name
2 parents bc44528 + 5147d48 commit 07947b1

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

src/main/java/com/redhat/labs/omp/service/EngagementService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.redhat.labs.omp.models.gitlab.FileAction;
2222
import com.redhat.labs.omp.models.gitlab.Group;
2323
import com.redhat.labs.omp.models.gitlab.Project;
24-
import com.redhat.labs.omp.models.gitlab.ProjectSearchResults;
2524
import com.redhat.labs.omp.utils.GitLabPathUtils;
2625

2726
@ApplicationScoped

src/main/java/com/redhat/labs/omp/service/GroupService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public Optional<Group> getGitLabGroupByName(String name, Integer parentId)
3737

3838
// look for a match between returned name and provided path
3939
for (Group group : groupList) {
40-
if (name.equals(group.getPath()) && parentId.equals(group.getParentId())) {
40+
if (name.equals(group.getName()) && parentId.equals(group.getParentId())) {
4141
return Optional.of(group);
4242
}
4343
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ public List<Group> getGroupByName(String name) {
5959

6060
if ("customer3".equalsIgnoreCase(name)) {
6161
groupList.add(Group.builder().id(3).name("customer1").path("customer1").build());
62-
} else if ("project4".equalsIgnoreCase(name)) {
63-
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());
62+
} else if ("project1".equalsIgnoreCase(name)) {
63+
groupList.add(Group.builder().id(4).name("project1").path("project1").parentId(11).build());
64+
} else if ("customer".equalsIgnoreCase(name) || "customer A".equalsIgnoreCase(name)) {
65+
groupList.add(Group.builder().id(11).name("customer A").path("customer-a").parentId(2).build());
6666
groupList.add(Group.builder().id(12).name("customer").path("customer").parentId(10).build());
6767
}
6868

src/test/java/com/redhat/labs/omp/resource/EngagementResourceTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,18 @@ public void testCreateEngagementSuccess() {
4343
.then()
4444
.statusCode(201);
4545
}
46-
46+
47+
@Test
48+
public void testUpdateEngagementSuccess() {
49+
given()
50+
.when()
51+
.contentType(ContentType.JSON)
52+
.queryParam("username", "jdoe")
53+
.queryParam("userEmail", "[email protected]")
54+
.body(ResourceLoader.load("engagement-update.json"))
55+
.post("/api/v1/engagements")
56+
.then()
57+
.statusCode(201);
58+
}
59+
4760
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"archive_date": "20210125",
3+
"customer_contact_email": "[email protected]",
4+
"customer_contact_name": "Reg Dunlop",
5+
"customer_name": "customer A",
6+
"description": "Charleston",
7+
"end_date": "20201225",
8+
"engagement_lead_email": "[email protected]",
9+
"engagement_lead_name": "Doug Gilmour",
10+
"project_id": 0,
11+
"location": "Raleigh, NC",
12+
"ocp_cloud_provider_name": "GCP",
13+
"ocp_cloud_provider_region": "West",
14+
"ocp_cluster_size": "medium",
15+
"ocp_persistent_storage_size": "50GB",
16+
"ocp_sub_domain": "jello",
17+
"ocp_version": "v4.2",
18+
"project_name": "project1",
19+
"start_date": "20200202",
20+
"technical_lead_email": "[email protected]",
21+
"technical_lead_name": "Wendel Clark"
22+
}

0 commit comments

Comments
 (0)