Search in sources :

Example 11 with DomainRoleEntry

use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.

the class GlobalDomainRoleControllerBeanTest method testRemove.

@Test
public void testRemove() {
    DomainRoleEntry domainRoleEntry = new DomainRoleEntry(USER_ID, DOMAINS, ROLE);
    when(domainRoleEntryManagerMock.removeByUserIdAndRole(USER_ID, ROLE)).thenReturn(domainRoleEntry);
    assertTrue(globalDomainRoleControllerSubject.removeDomainRole(USER_ID, ROLE));
    verify(domainRoleEntryManagerMock).removeByUserIdAndRole(eq(USER_ID), eq(ROLE));
    verify(globalDomainRoleControllerSubscriptionPublisherMock).fireDomainRoleEntryChanged(eq(ChangeType.REMOVE), eq(domainRoleEntry), eq(USER_PARTITION));
}
Also used : DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry) Test(org.junit.Test)

Example 12 with DomainRoleEntry

use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.

the class DomainRoleEntryManagerTest method testUpdateExistingEntry.

@Test
public void testUpdateExistingEntry() {
    String userId = "user";
    DomainRoleEntryEntity entity = create(userId, Sets.newHashSet("domain1", "domain2"), Role.OWNER);
    flushAndClear();
    DomainRoleEntry updatedEntry = new DomainRoleEntry(userId, new String[] { "domain3" }, Role.OWNER);
    CreateOrUpdateResult<DomainRoleEntry> result = subject.createOrUpdate(updatedEntry);
    flushAndClear();
    assertNotNull(result);
    assertEquals(ChangeType.UPDATE, result.getChangeType());
    assertEquals(userId, result.getEntry().getUid());
    assertEquals(Role.OWNER, result.getEntry().getRole());
    assertNotNull(result.getEntry().getRole());
    assertEquals(1, result.getEntry().getDomains().length);
    assertEquals("domain3", result.getEntry().getDomains()[0]);
}
Also used : DomainRoleEntryEntity(io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity) DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry) Test(org.junit.Test)

Example 13 with DomainRoleEntry

use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.

the class DomainRoleEntryManagerTest method testRemoveExistingEntry.

@Test
public void testRemoveExistingEntry() {
    String userId = "user";
    create(userId, Sets.newHashSet(), Role.OWNER);
    flushAndClear();
    DomainRoleEntry result = subject.removeByUserIdAndRole(userId, Role.OWNER);
    flushAndClear();
    assertNotNull(result);
    DomainRoleEntry[] byUserId = subject.findByUserId(userId);
    assertNotNull(byUserId);
    assertEquals(0, byUserId.length);
}
Also used : DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry) Test(org.junit.Test)

Example 14 with DomainRoleEntry

use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.

the class GlobalDomainAccessStoreAdminEhCache method getAllDomainRoleEntries.

@Override
public List<DomainRoleEntry> getAllDomainRoleEntries() {
    List<DomainRoleEntry> result = Lists.newArrayList();
    Cache roleCache = getCache(CacheId.DOMAIN_ROLES);
    Map<Object, Element> roleMap = roleCache.getAll(roleCache.getKeys());
    Iterator<Map.Entry<Object, Element>> iterator = roleMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Element thisElement = iterator.next().getValue();
        DomainRoleEntry objectValue = getElementValue(thisElement);
        result.add(objectValue);
    }
    return result;
}
Also used : DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry) MasterAccessControlEntry(joynr.infrastructure.DacTypes.MasterAccessControlEntry) OwnerAccessControlEntry(joynr.infrastructure.DacTypes.OwnerAccessControlEntry) Element(net.sf.ehcache.Element) DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry) DomainAccessControlStoreEhCache(io.joynr.accesscontrol.DomainAccessControlStoreEhCache) Cache(net.sf.ehcache.Cache)

Example 15 with DomainRoleEntry

use of joynr.infrastructure.DacTypes.DomainRoleEntry in project joynr by bmwcarit.

the class GlobalDomainRoleControllerProviderImpl method removeDomainRole.

@Override
public Promise<RemoveDomainRoleDeferred> removeDomainRole(String uid, Role role) {
    RemoveDomainRoleDeferred deferred = new RemoveDomainRoleDeferred();
    boolean removeSuccess = domainAccessStore.removeDomainRole(uid, role);
    if (removeSuccess) {
        // To notify DRE removal only primary keys (user ID and role) must
        // be set. All other fields are undefined.
        DomainRoleEntry removedEntry = new DomainRoleEntry(uid, null, role);
        fireDomainRoleEntryChanged(ChangeType.REMOVE, removedEntry);
    }
    deferred.resolve(removeSuccess);
    return new Promise<RemoveDomainRoleDeferred>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) DomainRoleEntry(joynr.infrastructure.DacTypes.DomainRoleEntry)

Aggregations

DomainRoleEntry (joynr.infrastructure.DacTypes.DomainRoleEntry)21 Test (org.junit.Test)8 MasterAccessControlEntry (joynr.infrastructure.DacTypes.MasterAccessControlEntry)7 OwnerAccessControlEntry (joynr.infrastructure.DacTypes.OwnerAccessControlEntry)6 Permission (joynr.infrastructure.DacTypes.Permission)4 TrustLevel (joynr.infrastructure.DacTypes.TrustLevel)4 Cache (net.sf.ehcache.Cache)4 Before (org.junit.Before)4 ArrayList (java.util.ArrayList)3 Query (net.sf.ehcache.search.Query)3 Results (net.sf.ehcache.search.Results)3 DomainRoleEntryEntity (io.joynr.accesscontrol.global.jee.persistence.DomainRoleEntryEntity)2 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)2 MessagingQos (io.joynr.messaging.MessagingQos)2 Result (net.sf.ehcache.search.Result)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DomainAccessControlStoreEhCache (io.joynr.accesscontrol.DomainAccessControlStoreEhCache)1 UserRoleKey (io.joynr.accesscontrol.primarykey.UserRoleKey)1 Promise (io.joynr.provider.Promise)1 ProxyBuilderFactoryImpl (io.joynr.proxy.ProxyBuilderFactoryImpl)1