private void validateCommunicationGroup( EntityTestCriteria contraints, CommunicationGroup communicationgroup) throws Exception { if (contraints.getRuleType() == MIN_MAX) { communicationgroup.isValid(); } else if (contraints.getRuleType() == NOT_NULL) { communicationgroup.isValid(); } else if (contraints.getRuleType() == REGEX) { communicationgroup.isValid(); } else if (contraints.getRuleType() == UNIQUE) { communicationgroupRepository.save(communicationgroup); } }
@Test public void test5NegativeTesting() throws NoSuchMethodException, SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, Exception { int failureCount = 0; for (EntityTestCriteria contraints : this.entityContraint) { try { CommunicationGroup communicationgroup = createCommunicationGroup(false); java.lang.reflect.Field field = null; if (!contraints.getFieldName().equalsIgnoreCase("CombineUniqueKey")) { field = communicationgroup.getClass().getDeclaredField(contraints.getFieldName()); } switch (((contraints.getTestId()))) { case 0: break; case 1: field.setAccessible(true); field.set(communicationgroup, null); validateCommunicationGroup(contraints, communicationgroup); failureCount++; break; case 2: communicationgroup.setCommGroupName(contraints.getNegativeValue().toString()); validateCommunicationGroup(contraints, communicationgroup); failureCount++; break; case 3: communicationgroup.setCommGroupDescription(contraints.getNegativeValue().toString()); validateCommunicationGroup(contraints, communicationgroup); failureCount++; break; } } catch (Exception e) { e.printStackTrace(); } } if (failureCount > 0) { org.junit.Assert.fail(); } }