urn_perun_member_attribute_def_def_membershipExpiration extends MemberAttributesModuleAbstract implements MemberAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, Member member, Attribute attribute) throws WrongAttributeValueException { String membershipExpTime = attribute.valueAsString(); if(membershipExpTime == null) return; Date testDate; try { testDate = BeansUtils.getDateFormatterWithoutTime().parse(membershipExpTime); } catch (ParseException ex) { throw new WrongAttributeValueException(attribute, "Date parsing failed", ex); } if (!BeansUtils.getDateFormatterWithoutTime().format(testDate).equals(membershipExpTime)) { throw new WrongAttributeValueException(attribute, "Wrong format yyyy-MM-dd expected."); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Member member, Attribute attribute); @Override Attribute fillAttribute(PerunSessionImpl perunSession, Member member, AttributeDefinition attribute); @Override void changedAttributeHook(PerunSessionImpl session, Member member, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCheckAttributeReturnNull() throws Exception { System.out.println("testCheckAttributeReturnNull()"); attributeToCheck.setValue(null); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }
@Test public void testCheckAttributeCommonValue() throws Exception { System.out.println("testCheckAttributeCommonValue()"); attributeToCheck.setValue("2001-12-25"); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }
@Test public void testCheckAttributeLowBorderValue() throws Exception { System.out.println("testCheckAttributeLowBorderValue()"); attributeToCheck.setValue("1000-01-01"); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }
@Test public void testCheckAttributeHighBorderValue() throws Exception { System.out.println("testCheckAttributeHighBorderValue()"); attributeToCheck.setValue("9999-12-31"); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongMonths() throws Exception { System.out.println("testCheckAttributeWrongMonth()"); attributeToCheck.setValue("1500-15-25"); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongYears() throws Exception { System.out.println("testCheckAttributeWrongYear()"); attributeToCheck.setValue("500-10-25"); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongDays() throws Exception { System.out.println("testCheckAttributeWrongDay()"); attributeToCheck.setValue("1500-10-32"); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongMonthWithBadDaysValueTime() throws Exception { System.out.println("testCheckAttributeWrongMonthWithBadDaysValueTime()"); attributeToCheck.setValue("3595-11-31"); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongCharInDate() throws Exception { System.out.println("testCheckAttributeWrongCharsInDate()"); attributeToCheck.setValue("3595-11-31s"); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeWrongCharsBetweenDate() throws Exception { System.out.println("testCheckAttributeWrongCharsBetweenDate()"); attributeToCheck.setValue("3595.11.31"); classInstance.checkAttributeSyntax(session, new Member(), attributeToCheck); }