Search in sources :

Example 6 with ICodeType

use of org.eclipse.scout.rt.shared.services.common.code.ICodeType in project scout.rt by eclipse.

the class CodeServiceTest method testInvlidateCodeType.

/**
 * Tests that a client notification is created when invalidating a code type
 * {@link CodeService#invalidateCodeType(Class)}
 */
@Test
public void testInvlidateCodeType() {
    ICodeService codeService = BEANS.get(ICodeService.class);
    codeService.getCodeType(SomeCodeType.class);
    // verify that execLoadCodes has been invoked and reset flag, so that next execLoadCodes can be detected
    assertTrue(SomeCodeType.EXEC_LOAD_CODES_INVOKED.getAndSet(false));
    codeService.invalidateCodeType(SomeCodeType.class);
    assertFalse(SomeCodeType.EXEC_LOAD_CODES_INVOKED.get());
    // check notification
    ArgumentCaptor<InvalidateCacheNotification> notification = ArgumentCaptor.forClass(InvalidateCacheNotification.class);
    verify(m_clientNotificationReg).putTransactionalForAllNodes(notification.capture(), anyBoolean());
    Set<Class<? extends ICodeType<?, ?>>> codeTypeClasses = ((CodeTypeCacheEntryFilter) notification.getValue().getFilter()).getCodeTypeClasses();
    assertEquals("CodeType list in the notification size", 1, codeTypeClasses.size());
    assertEquals("CodeType list(0) class", SomeCodeType.class, codeTypeClasses.iterator().next());
    // get codetype manually
    codeService.getCodeType(SomeCodeType.class);
    assertTrue(SomeCodeType.EXEC_LOAD_CODES_INVOKED.get());
}
Also used : ICodeType(org.eclipse.scout.rt.shared.services.common.code.ICodeType) CodeTypeCacheEntryFilter(org.eclipse.scout.rt.shared.services.common.code.CodeTypeCacheEntryFilter) ICodeService(org.eclipse.scout.rt.shared.services.common.code.ICodeService) InvalidateCacheNotification(org.eclipse.scout.rt.shared.cache.InvalidateCacheNotification) Test(org.junit.Test)

Example 7 with ICodeType

use of org.eclipse.scout.rt.shared.services.common.code.ICodeType in project scout.rt by eclipse.

the class CodeServiceClientProxyTest method createServiceUnderTest.

private static CodeService createServiceUnderTest() {
    CodeService serviceUnderTest = new CodeService() {

        @Override
        public Set<Class<? extends ICodeType<?, ?>>> getAllCodeTypeClasses() {
            Set<Class<? extends ICodeType<?, ?>>> hashSet = new HashSet<>();
            hashSet.add(CompanyRatingCodeType.class);
            hashSet.add(CompanyTypeCodeType.class);
            return hashSet;
        }
    };
    BeanInstanceUtil.initializeBeanInstance(serviceUnderTest);
    return serviceUnderTest;
}
Also used : ICodeType(org.eclipse.scout.rt.shared.services.common.code.ICodeType) CodeService(org.eclipse.scout.rt.shared.services.common.code.CodeService) HashSet(java.util.HashSet)

Aggregations

ICodeType (org.eclipse.scout.rt.shared.services.common.code.ICodeType)7 InvalidateCacheNotification (org.eclipse.scout.rt.shared.cache.InvalidateCacheNotification)4 CodeTypeCacheEntryFilter (org.eclipse.scout.rt.shared.services.common.code.CodeTypeCacheEntryFilter)4 ICodeService (org.eclipse.scout.rt.shared.services.common.code.ICodeService)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)1 CodeService (org.eclipse.scout.rt.shared.services.common.code.CodeService)1