-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
1e31245
commit 16e8778
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ | |
import java.util.TimeZone; | ||
import java.util.UUID; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.http.client.HttpResponseException; | ||
|
@@ -519,6 +520,28 @@ void patch_userNameChange_as_same_user_200_ok(TestInfo test) throws HttpResponse | |
assertEquals(newDisplayName, user.getDisplayName()); | ||
} | ||
|
||
@Test | ||
void patch_teamAddition_200_ok(TestInfo test) throws HttpResponseException, JsonProcessingException { | ||
TeamResourceTest teamResourceTest = new TeamResourceTest(); | ||
EntityReference team1 = | ||
teamResourceTest.createEntity(teamResourceTest.createRequest(test, 1), ADMIN_AUTH_HEADERS).getEntityReference(); | ||
User user = | ||
createEntity( | ||
createRequest(test, 10) | ||
.withName("testUser1") | ||
.withDisplayName("displayName") | ||
.withEmail("[email protected]"), | ||
authHeaders("[email protected]")); | ||
String userJson = JsonUtils.pojoToJson(user); | ||
List<EntityReference> teams = user.getTeams(); | ||
teams.add(team1); | ||
user.setTeams(teams); // Update the teams | ||
user = patchEntity(user.getId(), userJson, user, ADMIN_AUTH_HEADERS); // Patch the user | ||
// Ensure default "Organization" team is not part of the patch response | ||
assertEquals(1, user.getTeams().size()); | ||
assertEquals(team1.getId(), user.getTeams().get(0).getId()); | ||
} | ||
|
||
@Test | ||
void patch_userAttributes_as_admin_200_ok(TestInfo test) throws IOException { | ||
// Create user without any attributes - ***Note*** isAdmin by default is false. | ||
|
@@ -793,6 +816,10 @@ public void validateCreatedEntity(User user, CreateUser createRequest, Map<Strin | |
} | ||
if (expectedTeams.isEmpty()) { | ||
expectedTeams = new ArrayList<>(List.of(ORG_TEAM.getEntityReference())); // Organization is default team | ||
} else { | ||
// Remove ORG_TEAM from the expected teams | ||
expectedTeams = | ||
expectedTeams.stream().filter(t -> !t.getId().equals(ORG_TEAM.getId())).collect(Collectors.toList()); | ||
} | ||
assertEntityReferences(expectedTeams, user.getTeams()); | ||
|
||
|