urn_perun_facility_attribute_def_def_homeDirUmask extends FacilityAttributesModuleAbstract implements FacilityAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws WrongAttributeValueException { String mask = attribute.valueAsString(); if (mask != null) { Matcher matcher = pattern.matcher(mask); if (!matcher.matches()) throw new WrongAttributeValueException(attribute, "Bad unix permission mask in attribute format " + mask); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Facility facility, Attribute attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testCheckAttributeSyntax() throws Exception { System.out.println("testCheckAttributeSyntax()"); Attribute attributeToCheck = new Attribute(); attributeToCheck.setValue(null); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); attributeToCheck.setValue("0542"); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); attributeToCheck.setValue("215"); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); attributeToCheck.setValue("0521"); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithWrongValue() throws Exception { System.out.println("testCheckAttributeSyntaxWithWrongValue()"); Attribute attributeToCheck = new Attribute(); attributeToCheck.setValue("5891"); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithWrongValueLength() throws Exception { System.out.println("testCheckAttributeSyntaxWithWrongValueLength()"); Attribute attributeToCheck = new Attribute(); attributeToCheck.setValue("12"); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); }