use of com.thinkbiganalytics.metadata.api.user.UserGroup in project kylo by Teradata.
the class KyloAuthConfig method createDefaultGroup.
protected UserGroup createDefaultGroup(String groupName, String title, String oldGroupName) {
UserGroup newGroup = userProvider.ensureGroup(groupName);
newGroup.setTitle(title);
// If there is an old group replacing this new group transfer the users before deleting it.
if (oldGroupName != null) {
userProvider.findGroupByName(oldGroupName).ifPresent(oldGrp -> {
oldGrp.getUsers().forEach(user -> newGroup.addUser(user));
userProvider.deleteGroup(oldGrp);
});
}
return newGroup;
}
use of com.thinkbiganalytics.metadata.api.user.UserGroup in project kylo by Teradata.
the class JcrUserProviderTest method testGroupGetAllContainingGroups.
@Test(dependsOnMethods = "testCreateMemberGroups")
public void testGroupGetAllContainingGroups() {
metadata.read(() -> {
UserGroup groupA = this.provider.findGroupByName("groupA").get();
UserGroup groupB = this.provider.findGroupByName("groupB").get();
UserGroup groupC = this.provider.findGroupByName("groupC").get();
UserGroup groupD = this.provider.findGroupByName("groupD").get();
assertThat(groupA.getAllContainingGroups()).isEmpty();
assertThat(groupB.getAllContainingGroups()).hasSize(1).extracting(g -> g.getSystemName()).contains("groupA");
assertThat(groupC.getAllContainingGroups()).hasSize(1).extracting(g -> g.getSystemName()).contains("groupA");
assertThat(groupD.getAllContainingGroups()).hasSize(2).extracting(g -> g.getSystemName()).contains("groupC", "groupA");
});
}
use of com.thinkbiganalytics.metadata.api.user.UserGroup in project kylo by Teradata.
the class JcrUserProviderTest method testCreateGroup.
@Test(dependsOnMethods = "testFindUsers")
public void testCreateGroup() {
UserGroup.ID id = metadata.commit(() -> {
UserGroup groupA = this.provider.createGroup("groupA");
assertThat(groupA).isNotNull();
return groupA.getId();
}, MetadataAccess.SERVICE);
metadata.read(() -> {
Optional<UserGroup> optional = this.provider.findGroupById(id);
assertThat(optional.isPresent()).isTrue();
}, MetadataAccess.SERVICE);
}
use of com.thinkbiganalytics.metadata.api.user.UserGroup in project kylo by Teradata.
the class JcrUserProviderTest method testCreateMemberGroups.
@Test(dependsOnMethods = "testCreateGroup")
public void testCreateMemberGroups() {
metadata.commit(() -> {
UserGroup groupA = this.provider.findGroupByName("groupA").get();
UserGroup groupB = this.provider.createGroup("groupB");
UserGroup groupC = this.provider.createGroup("groupC");
UserGroup groupD = this.provider.createGroup("groupD");
assertThat(groupA.addGroup(groupB)).isTrue();
assertThat(groupA.addGroup(groupC)).isTrue();
assertThat(groupC.addGroup(groupD)).isTrue();
}, MetadataAccess.SERVICE);
}
use of com.thinkbiganalytics.metadata.api.user.UserGroup in project kylo by Teradata.
the class JcrUserProviderTest method testGetUsers.
@Test(dependsOnMethods = "testAddUsersMembers")
public void testGetUsers() {
metadata.read(() -> {
UserGroup groupA = this.provider.findGroupByName("groupA").get();
UserGroup groupB = this.provider.findGroupByName("groupB").get();
UserGroup groupC = this.provider.findGroupByName("groupC").get();
UserGroup groupD = this.provider.findGroupByName("groupD").get();
assertThat(groupA.getUsers()).extracting(User::getSystemName).containsExactly("user1");
assertThat(groupB.getUsers()).extracting(User::getSystemName).containsExactly("user2");
assertThat(groupD.getUsers()).extracting(User::getSystemName).containsExactly("user3");
assertThat(groupC.getUsers()).hasSize(0);
});
}
Aggregations