private void validateUser(EntityTestCriteria contraints, User user) throws Exception {
   if (contraints.getRuleType() == MIN_MAX) {
     user.isValid();
   } else if (contraints.getRuleType() == NOT_NULL) {
     user.isValid();
   } else if (contraints.getRuleType() == REGEX) {
     user.isValid();
   } else if (contraints.getRuleType() == UNIQUE) {
     userRepository.save(user);
   }
 }
 @Test
 public void test1Save() {
   try {
     User user = createUser(true);
     user.setEntityAudit(1, "xyz", RECORD_TYPE.ADD);
     user.isValid();
     userRepository.save(user);
     map.put("UserPrimaryKey", user._getPrimarykey());
   } catch (java.lang.Exception e) {
     org.junit.Assert.fail(e.getMessage());
   }
 }
 @Test
 public void test5NegativeTesting()
     throws NoSuchMethodException, SecurityException, IllegalArgumentException,
         IllegalAccessException, NoSuchFieldException, Exception {
   int failureCount = 0;
   for (EntityTestCriteria contraints : this.entityContraint) {
     try {
       User user = createUser(false);
       java.lang.reflect.Field field = null;
       if (!contraints.getFieldName().equalsIgnoreCase("CombineUniqueKey")) {
         field = user.getClass().getDeclaredField(contraints.getFieldName());
       }
       switch (((contraints.getTestId()))) {
         case 0:
           break;
         case 1:
           user.setUserAccessCode(Integer.parseInt(contraints.getNegativeValue().toString()));
           validateUser(contraints, user);
           failureCount++;
           break;
         case 2:
           user.setMultiFactorAuthEnabled(
               Integer.parseInt(contraints.getNegativeValue().toString()));
           validateUser(contraints, user);
           failureCount++;
           break;
         case 3:
           user.setGenTempOneTimePassword(
               Integer.parseInt(contraints.getNegativeValue().toString()));
           validateUser(contraints, user);
           failureCount++;
           break;
         case 4:
           user.setAllowMultipleLogin(Integer.parseInt(contraints.getNegativeValue().toString()));
           validateUser(contraints, user);
           failureCount++;
           break;
         case 5:
           user.setIsLocked(Integer.parseInt(contraints.getNegativeValue().toString()));
           validateUser(contraints, user);
           failureCount++;
           break;
         case 6:
           user.setIsDeleted(Integer.parseInt(contraints.getNegativeValue().toString()));
           validateUser(contraints, user);
           failureCount++;
           break;
         case 7:
           user.setChangePasswordNextLogin(
               Integer.parseInt(contraints.getNegativeValue().toString()));
           validateUser(contraints, user);
           failureCount++;
           break;
         case 8:
           user.setPasswordAlgo(contraints.getNegativeValue().toString());
           validateUser(contraints, user);
           failureCount++;
           break;
         case 9:
           user.setSessionTimeout(Integer.parseInt(contraints.getNegativeValue().toString()));
           validateUser(contraints, user);
           failureCount++;
           break;
       }
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   if (failureCount > 0) {
     org.junit.Assert.fail();
   }
 }
 private User createUser(Boolean isSave) throws Exception {
   UserAccessDomain useraccessdomain = new UserAccessDomain();
   useraccessdomain.setDomainIcon("HhVn5DAWiHKFl29WJ3yCa20Qp2Xw0mCof5DZ3SO6oYx5Sht4VL");
   useraccessdomain.setDomainDescription("Plnpg9MTYoTdEM1zpM3kcpVfaJeyipNjTAUORBj3NMZlmn0Lur");
   useraccessdomain.setDomainName("FkQWrLCQNScFsJCg4WU9yjDyAQLghxHSI0RhiSJZTl3thVI6nW");
   useraccessdomain.setUserAccessDomain(valueGenerator.getRandomInteger(99999, 0));
   useraccessdomain.setDomainHelp("5RiQAtDuDX5mRO2Dv7O1xfDzzItT0Z0oGGU1hDqBCRg5V3fLAJ");
   UserAccessDomain UserAccessDomainTest = new UserAccessDomain();
   if (isSave) {
     UserAccessDomainTest = useraccessdomainRepository.save(useraccessdomain);
     map.put("UserAccessDomainPrimaryKey", useraccessdomain._getPrimarykey());
   }
   UserAccessLevel useraccesslevel = new UserAccessLevel();
   useraccesslevel.setLevelHelp("AtdGNt4KtBlsLIJXj4dklWrOHMdkdKr1aEUUs3Ryw5wOCsd4A5");
   useraccesslevel.setUserAccessLevel(valueGenerator.getRandomInteger(99999, 0));
   useraccesslevel.setLevelIcon("IHAWafpfsaodmPRrPw5lksoaHfop6nx3vsnp9ffuT09TrFiCHR");
   useraccesslevel.setLevelName("pnr4Kn1EvG4G7wjdeN3agTc80gKt9HQko7VUggfLQPm5rJvBhF");
   useraccesslevel.setLevelDescription("Iyumk4lQMDpDtHtNmiuhVDO0IX2lNxF82n4K6n6YjPJf1fi5fW");
   UserAccessLevel UserAccessLevelTest = new UserAccessLevel();
   if (isSave) {
     UserAccessLevelTest = useraccesslevelRepository.save(useraccesslevel);
     map.put("UserAccessLevelPrimaryKey", useraccesslevel._getPrimarykey());
   }
   User user = new User();
   user.setMultiFactorAuthEnabled(1);
   user.setUserAccessCode(1891);
   user.setIsLocked(1);
   user.setIsDeleted(1);
   user.setGenTempOneTimePassword(1);
   user.setUserAccessDomainId(
       (java.lang.String)
           UserAccessDomainTest._getPrimarykey()); /* ******Adding refrenced table data */
   user.setAllowMultipleLogin(1);
   user.setLastPasswordChangeDate(new java.sql.Timestamp(1461751809985l));
   user.setChangePasswordNextLogin(1);
   user.setSessionTimeout(2035);
   user.setUserAccessLevelId(
       (java.lang.String)
           UserAccessLevelTest._getPrimarykey()); /* ******Adding refrenced table data */
   user.setPasswordExpiryDate(new java.sql.Timestamp(1461751810016l));
   user.setPasswordAlgo("EssiOW6TXoGycWmTTc46Vqzcu54OC0CcAv2Vze3D2Bbb27EayI");
   java.util.List<PassRecovery> listOfPassRecovery = new java.util.ArrayList<PassRecovery>();
   PassRecovery passrecovery = new PassRecovery();
   Question question = new Question();
   question.setQuestionDetails("XDaanRFikD");
   question.setQuestionIcon("O11GnUoCDFtUKqKe2RgQ8aAEiNNYHH8eG55ub46ctsCh2YaTEJ");
   question.setLevelid(9);
   question.setQuestion("HvdolS7AacTYKIlr2oonerZmHERhZdLgh1ioJWRXutHqcIiUqq");
   Question QuestionTest = new Question();
   if (isSave) {
     QuestionTest = questionRepository.save(question);
     map.put("QuestionPrimaryKey", question._getPrimarykey());
   }
   passrecovery.setQuestionId((java.lang.String) QuestionTest._getPrimarykey());
   passrecovery.setAnswer("2O4o57qo2yC8aOg7vANB68z02t8NDir1Io7S9Cv7JO0ahzucyl");
   passrecovery.setUser(user);
   listOfPassRecovery.add(passrecovery);
   user.addAllPassRecovery(listOfPassRecovery);
   UserData userdata = new UserData();
   userdata.setOneTimePassword("1HaL5x1zEKiSF9er0GKXoRn1EymuuErJ");
   userdata.setOneTimePassword("4xkFO1xaUqketd3qDr8osVhuHwARJsyL");
   userdata.setUser(user);
   userdata.setOneTimePasswordExpiry(10);
   userdata.setPassword("5PKlrIdiww6OWBqk5UVBZTy1lz9uqUYuMk4z0O3PUfkfTCQt9m");
   userdata.setLast5Passwords("L7BsFKVOF21UNyqGEnOrccHIT1cobz7NOX101e5SsOPxGUC0Ya");
   userdata.setOneTimePasswordGenDate(new java.sql.Timestamp(1461751810214l));
   user.setUserData(userdata);
   user.setEntityValidator(entityValidator);
   return user;
 }