urn_perun_user_facility_attribute_def_def_accountExpirationTime extends UserFacilityAttributesModuleAbstract implements UserFacilityAttributesModuleImplApi { @Override public Attribute fillAttribute(PerunSessionImpl perunSession, User user, Facility facility, AttributeDefinition attribute) throws WrongAttributeAssignmentException { Attribute ret = new Attribute(attribute); List<Integer> resourcesExpTimes = new ArrayList<>(); Integer resourceExpTime; for (Resource r : perunSession.getPerunBl().getUsersManagerBl().getAllowedResources(perunSession, facility, user)) { try { resourceExpTime = (Integer) perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, r, attribute.getName()).getValue(); if (resourceExpTime != null) { resourcesExpTimes.add(resourceExpTime); } } catch (AttributeNotExistsException ex) { throw new InternalErrorException(ex); } } Integer facilityAccExpTime; try { facilityAccExpTime = (Integer) perunSession.getPerunBl().getAttributesManagerBl().getAttribute(perunSession, facility, attribute.getName()).getValue(); } catch (AttributeNotExistsException ex) { throw new InternalErrorException(ex); } if (facilityAccExpTime != null) { resourcesExpTimes.add(facilityAccExpTime); } ret.setValue(Collections.min(resourcesExpTimes)); return ret; }  @Override void checkAttributeSemantics(PerunSessionImpl perunSession, User user, Facility facility, Attribute attribute); @Override List<String> getDependencies(); @Override Attribute fillAttribute(PerunSessionImpl perunSession, User user, Facility facility, AttributeDefinition attribute); @Override AttributeDefinition getAttributeDefinition();  }
@Test public void testFillAttributeValue() throws Exception { System.out.println("testFillAttributeValue()"); when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Facility.class), anyString())).thenReturn(new Attribute() { { setValue(999); } }); when(session.getPerunBl().getAttributesManagerBl().getAttribute(any(PerunSession.class), any(Resource.class), anyString())).thenReturn(new Attribute() { { setValue(1000); } },new Attribute() { { setValue(1001); } }); attributeToCheck = classInstance.fillAttribute(session, new User(), new Facility(), attributeToCheck); assertEquals("Filled attribute should be the lowest from all resource and facility values", 999,attributeToCheck.getValue()); }