urn_perun_facility_attribute_def_def_quotaEnabled extends FacilityAttributesModuleAbstract implements FacilityAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws WrongAttributeValueException { if(attribute.getValue() == null) return; Integer quotaEnabled = attribute.valueAsInteger(); if(quotaEnabled > 1 || quotaEnabled < 0) throw new WrongAttributeValueException(attribute, facility, "Attribute has only two possible options for quota: 0 - means not enabled, 1 - means enabled."); }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Facility facility, Attribute attribute); @Override Attribute fillAttribute(PerunSessionImpl session, Facility facility, AttributeDefinition attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithTooLargeValue() throws Exception { System.out.println("testCheckAttributeSyntaxWithIncorrectValue()"); attributeToCheck.setValue(5); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); }
@Test(expected = WrongAttributeValueException.class) public void testCheckAttributeSyntaxWithTooSmallValue() throws Exception { System.out.println("testCheckAttributeSyntaxWithIncorrectValue()"); attributeToCheck.setValue(-1); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); }
@Test public void testCheckAttributeSyntaxCorrect() throws Exception { System.out.println("testCheckAttributeSyntaxCorrect()"); attributeToCheck.setValue(null); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); attributeToCheck.setValue(0); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); attributeToCheck.setValue(1); classInstance.checkAttributeSyntax(session, facility, attributeToCheck); }