urn_perun_group_attribute_def_def_lastSynchronizationTimestamp extends GroupAttributesModuleAbstract implements GroupAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl sess, Group group, Attribute attribute) throws WrongAttributeValueException { if(attribute.getValue() == null) return; String attrValue = attribute.valueAsString(); try { Date date = BeansUtils.getDateFormatter().parse(attrValue); } catch (ParseException ex) { throw new WrongAttributeValueException(attribute, group, "Format of timestamp is not correct and can't be parsed correctly. Ex. 'yyyy-MM-dd HH:mm:ss.S'", ex); } }  @Override void checkAttributeSyntax(PerunSessionImpl sess, Group group, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCheckAttributeReturnNull() throws Exception { System.out.println("testCheckAttriubuteReturnNull()"); attributeToCheck.setValue(null); classInstance.checkAttributeSyntax(sess, group, attributeToCheck); }
@Test public void testCheckCorrectSyntax() throws Exception { System.out.println("testCheckCorrectSyntax()"); attributeToCheck.setValue("2001-12-25 22:22:22.0"); classInstance.checkAttributeSyntax(sess, group, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongMonths() throws Exception { System.out.println("testCheckAttributeWrongMonth()"); attributeToCheck.setValue("1500-15-25 22:22:22.0"); classInstance.checkAttributeSyntax(sess, group, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongTime() throws Exception { System.out.println("testCheckAttributeWrongYear()"); attributeToCheck.setValue("500-10-25 25:22:22.0"); classInstance.checkAttributeSyntax(sess, group, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongDays() throws Exception { System.out.println("testCheckAttributeWrongDay()"); attributeToCheck.setValue("1500-10-32 22:22:22.0"); classInstance.checkAttributeSyntax(sess, group, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongMonthWithBadDaysValueTime() throws Exception { System.out.println("testCheckAttributeWrongMonthWithBadDaysValueTime()"); attributeToCheck.setValue("3595-11-31 22:22:22.0"); classInstance.checkAttributeSyntax(sess, group, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongCharInDate() throws Exception { System.out.println("testCheckAttributeWrongCharsInDate()"); attributeToCheck.setValue("3595-11-31s 22:22:22.0"); classInstance.checkAttributeSyntax(sess, group, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongCharsBetweenDate() throws Exception { System.out.println("testCheckAttributeWrongCharsBetweenDate()"); attributeToCheck.setValue("3595.11.31 22:22:22.0"); classInstance.checkAttributeSyntax(sess, group, attributeToCheck); }