public void testNonImplementorsHaveNoIndicatorValuesProblem() { String problem = ProblemConstants.MAPPING_CLASS_INDICATOR_VALUES_INVALID; SimpleContactProject project = new SimpleContactProject(); MWVariableOneToOneMapping mapping = (MWVariableOneToOneMapping) project.getPersonImplDescriptor().mappingNamed("contact"); assertTrue( "The mapping should not have the problem: " + problem, !hasProblem(problem, mapping)); MWRelationalClassIndicatorFieldPolicy policy = mapping.getClassIndicatorPolicy(); try { MWClassIndicatorValue value = (MWClassIndicatorValue) ClassTools.attemptNewInstance( MWClassIndicatorValue.class, new Class[] { MWClassIndicatorFieldPolicy.class, MWMappingDescriptor.class, Object.class }, new Object[] {policy, project.getPersonImplDescriptor(), "I"}); value.setInclude(true); Collection indicatorValues = (Collection) ClassTools.attemptToGetFieldValue(policy, "classIndicatorValues"); indicatorValues.add(value); } catch (NoSuchFieldException exception) { // test will fail } catch (NoSuchMethodException exception) { // test will fail } assertTrue("The mapping should have the problem: " + problem, hasProblem(problem, mapping)); }
public void testHasIndicatorValuesProblem() { String problem = ProblemConstants.NO_CLASS_INDICATOR_FOR_INCLUDED_CLASS; SimpleContactProject project = new SimpleContactProject(); MWVariableOneToOneMapping mapping = (MWVariableOneToOneMapping) project.getPersonImplDescriptor().mappingNamed("contact"); assertTrue( "The mapping should not have the problem: " + problem, !hasProblem(problem, mapping)); Iterator values = mapping.getClassIndicatorPolicy().classIndicatorValues(); while (values.hasNext()) { MWClassIndicatorValue value = (MWClassIndicatorValue) values.next(); value.setIndicatorValue(null); } assertTrue("The mapping should have the problem: " + problem, hasProblem(problem, mapping)); }