use of org.jaffa.rules.meta.MetaDataRepository in project jaffa-framework by jaffa-projects.
the class GenericForeignKeyValidatorTest method setup.
/**
* Setup all tests.
*/
@Before
public void setup() throws Exception {
testModel.setUOW(new TestUOW());
testModel.setField1("Key123");
// This is what the validator factory would build up.
MetaDataRepository repo = MetaDataRepository.instance();
target.setRuleMap(repo.getPropertyRuleMap(TestModel.class.getName(), "generic-foreign-key"));
}
use of org.jaffa.rules.meta.MetaDataRepository in project jaffa-framework by jaffa-projects.
the class CxfFunctionGuardInterceptorTest method testInterceptor.
@Test
public void testInterceptor() throws NoSuchMethodException, FrameworkException, ApplicationExceptions {
// Mock the security manager
PowerMockito.mockStatic(SecurityManager.class);
PowerMockito.when(SecurityManager.checkFunctionAccess("Test")).thenReturn(true);
// Mock the Rule helper factory and the rule it returns
mockStatic(RuleHelperFactory.class);
IRuleHelper ruleHelperFactory = mock(IRuleHelper.class);
when(RuleHelperFactory.instance(Mockito.anyString())).thenReturn(ruleHelperFactory);
// Mock the metadata repository
mockStatic(MetaDataRepository.class);
MetaDataRepository repository = mock(MetaDataRepository.class);
when(MetaDataRepository.instance()).thenReturn(repository);
// Create a real instance of an interceptor
CxfFunctionGuardInterceptor interceptor = new CxfFunctionGuardInterceptor();
// Successful access - matching method and name
updateRules("Test", "Test", repository, ruleHelperFactory);
interceptor.handleMessage(getMockMessage());
// Failed access - matching method not valid name
Fault fault = null;
try {
updateRules("Fail", "Test", repository, ruleHelperFactory);
interceptor.handleMessage(getMockMessage());
} catch (Fault f) {
fault = f;
}
Assert.assertNotNull("Fault should have been thrown du to failed access", fault);
// Successful access - not matching method, so rules not enforced
updateRules("xxxxx", "NoMatch", repository, ruleHelperFactory);
interceptor.handleMessage(getMockMessage());
}
use of org.jaffa.rules.meta.MetaDataRepository in project jaffa-framework by jaffa-projects.
the class PartialForeignKeyValidatorTest method setup.
/**
* Setup all tests.
*/
@Before
public void setup() throws Exception {
testModel.setUOW(new TestUOW());
testModel.setField1("Key123");
// This is what the validator factory would build up.
MetaDataRepository repo = MetaDataRepository.instance();
target.setRuleMap(repo.getPropertyRuleMap(TestModel.class.getName(), "partial-foreign-key"));
}
Aggregations