@Test public void test5NegativeTesting() throws NoSuchMethodException, SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchFieldException, Exception { int failureCount = 0; for (EntityTestCriteria contraints : this.entityContraint) { try { ThirdEn thirden = createThirdEn(false); java.lang.reflect.Field field = null; if (!contraints.getFieldName().equalsIgnoreCase("CombineUniqueKey")) { field = thirden.getClass().getDeclaredField(contraints.getFieldName()); } switch (((contraints.getTestId()))) { case 0: break; case 1: field.setAccessible(true); field.set(thirden, null); validateThirdEn(contraints, thirden); failureCount++; break; case 2: thirden.setFirsname1(contraints.getNegativeValue().toString()); validateThirdEn(contraints, thirden); failureCount++; break; } } catch (Exception e) { e.printStackTrace(); } } if (failureCount > 0) { org.junit.Assert.fail(); } }
private void validateThirdEn(EntityTestCriteria contraints, ThirdEn thirden) throws Exception { if (contraints.getRuleType() == MIN_MAX) { thirden.isValid(); } else if (contraints.getRuleType() == NOT_NULL) { thirden.isValid(); } else if (contraints.getRuleType() == REGEX) { thirden.isValid(); } else if (contraints.getRuleType() == UNIQUE) { thirdenRepository.save(thirden); } }
@Test public void test1Save() { try { ThirdEn thirden = createThirdEn(true); thirden.setEntityAudit(1, "xyz", RECORD_TYPE.ADD); thirden.isValid(); thirdenRepository.save(thirden); map.put("ThirdEnPrimaryKey", thirden._getPrimarykey()); } catch (com.athena.framework.server.exception.biz.SpartanConstraintViolationException e) { org.junit.Assert.fail(e.getMessage()); } catch (java.lang.Exception e) { org.junit.Assert.fail(e.getMessage()); } }
@Test public void test2Update() { try { org.junit.Assert.assertNotNull(map.get("ThirdEnPrimaryKey")); ThirdEn thirden = thirdenRepository.findById((java.lang.String) map.get("ThirdEnPrimaryKey")); thirden.setFirsname1("R3Xb3U9uBkRkniwnr16YblkOFRQ51r0opw905ji1OV3HV9onz5"); thirden.setVersionId(1); thirden.setEntityAudit(1, "xyz", RECORD_TYPE.UPDATE); thirdenRepository.update(thirden); } catch (com.athena.framework.server.exception.repository.SpartanPersistenceException e) { org.junit.Assert.fail(e.getMessage()); } catch (java.lang.Exception e) { org.junit.Assert.fail(e.getMessage()); } }
private ThirdEn createThirdEn(Boolean isSave) throws Exception { ThirdEn thirden = new ThirdEn(); thirden.setFirsname1("XkjOgCQK3uiy3PDXsQbUk2tKbhTf7NpyaeIeKdbnOdik0moEMZ"); thirden.setEntityValidator(entityValidator); return thirden; }