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());
}
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;
}
Aggregations