urn_perun_resource_attribute_def_def_accountExpirationTime extends ResourceAttributesModuleAbstract implements ResourceAttributesModuleImplApi { @Override public void checkAttributeSemantics(PerunSessionImpl perunSession, Resource resource, Attribute attribute) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException { Integer accExpTime = attribute.valueAsInteger(); if(accExpTime == null) { throw new WrongReferenceAttributeValueException(attribute, null, resource, null, "Attribute value shouldn't be null"); } Facility fac = perunSession.getPerunBl().getResourcesManagerBl().getFacility(perunSession, resource); Attribute facilityAccExpTimeAttribute; try { facilityAccExpTimeAttribute = perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, fac, A_F_accountExpirationTime); } catch (AttributeNotExistsException ex) { throw new InternalErrorException(ex); } Integer facilityAccExpTime = facilityAccExpTimeAttribute.valueAsInteger(); if(facilityAccExpTime == null) { throw new WrongReferenceAttributeValueException(attribute, facilityAccExpTimeAttribute, resource, null, fac, null, "cant determine attribute value on underlying facility"); } if(facilityAccExpTime < accExpTime) { throw new WrongReferenceAttributeValueException(attribute, facilityAccExpTimeAttribute, resource, null, fac, null, "value can be higher than same facility attribute"); } }  @Override Attribute fillAttribute(PerunSessionImpl perunSession, Resource resource, AttributeDefinition attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Resource resource, Attribute attribute); @Override List<String> getDependencies(); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongReferenceAttributeValueException.class) public void testSemanticsWithNullValue() throws Exception { System.out.println("testSemanticsWithNullValue()"); attributeToCheck.setValue(null); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }
@Test(expected = WrongReferenceAttributeValueException.class) public void testSemanticsReqAttributeWithNullValue() throws Exception { System.out.println("testSemanticsReqAttributeWithNullValue()"); reqAttribute.setValue(null); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }
@Test(expected = WrongReferenceAttributeValueException.class) public void testSemanticsReqAttributeWithLesserValue() throws Exception { System.out.println("testSemanticsReqAttributeWithLesserValue()"); attributeToCheck.setValue(6); reqAttribute.setValue(5); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }
@Test public void testSemanticsCorrect() throws Exception { System.out.println("testSemanticsCorrect()"); attributeToCheck.setValue(4); reqAttribute.setValue(5); classInstance.checkAttributeSemantics(sess, resource, attributeToCheck); }