use of com.google.gerrit.server.plugincontext.PluginSetContext in project gerrit by GerritCodeReview.
the class UniversalGroupBackendTest method setup.
@Before
public void setup() {
user = mock(IdentifiedUser.class);
backends = new DynamicSet<>();
backends.add("gerrit", new SystemGroupBackend(new Config()));
backend = new UniversalGroupBackend(new PluginSetContext<>(backends, PluginMetrics.DISABLED_INSTANCE));
}
use of com.google.gerrit.server.plugincontext.PluginSetContext in project gerrit by GerritCodeReview.
the class UniversalGroupBackendTest method otherMemberships.
@Test
public void otherMemberships() {
final AccountGroup.UUID handled = AccountGroup.uuid("handled");
final AccountGroup.UUID notHandled = AccountGroup.uuid("not handled");
final IdentifiedUser member = mock(IdentifiedUser.class);
final IdentifiedUser notMember = mock(IdentifiedUser.class);
GroupBackend backend = mock(GroupBackend.class);
when(backend.handles(eq(handled))).thenReturn(true);
when(backend.handles(not(eq(handled)))).thenReturn(false);
when(backend.membershipsOf(any(IdentifiedUser.class))).thenAnswer(new Answer<GroupMembership>() {
@Override
public GroupMembership answer(InvocationOnMock invocation) {
GroupMembership membership = mock(GroupMembership.class);
when(membership.contains(eq(handled))).thenReturn(invocation.getArguments()[0] == member);
when(membership.contains(eq(notHandled))).thenReturn(false);
return membership;
}
});
backends = new DynamicSet<>();
backends.add("gerrit", backend);
backend = new UniversalGroupBackend(new PluginSetContext<>(backends, PluginMetrics.DISABLED_INSTANCE));
GroupMembership checker = backend.membershipsOf(member);
assertFalse(checker.contains(REGISTERED_USERS));
assertFalse(checker.contains(OTHER_UUID));
assertTrue(checker.contains(handled));
assertFalse(checker.contains(notHandled));
checker = backend.membershipsOf(notMember);
assertFalse(checker.contains(handled));
assertFalse(checker.contains(notHandled));
}
Aggregations