urn_perun_user_facility_attribute_def_def_o365AccountExtension extends UserFacilityAttributesModuleAbstract implements UserFacilityAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Facility facility, Attribute attribute) throws WrongAttributeValueException { String o365AccExtTime = attribute.valueAsString(); if(o365AccExtTime == null) return; Date testDate; try { testDate = BeansUtils.getDateFormatterWithoutTime().parse(o365AccExtTime); } catch (ParseException ex) { throw new WrongAttributeValueException(attribute, "Date parsing failed", ex); } if (!BeansUtils.getDateFormatterWithoutTime().format(testDate).equals(o365AccExtTime)) { throw new WrongAttributeValueException(attribute, "Wrong format, yyyy-mm-dd expected."); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, User user, Facility facility, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void testSyntaxWithWrongFormat() throws Exception { System.out.println("testSyntaxWithWrongFormat()"); attributeToCheck.setValue("2018-31-12"); classInstance.checkAttributeSyntax(sess, user, facility, attributeToCheck); }
@Test public void testSyntaxCorrect() throws Exception { System.out.println("testSyntaxCorrect()"); attributeToCheck.setValue("2018-12-31"); classInstance.checkAttributeSyntax(sess, user, facility, attributeToCheck); }