urn_perun_group_resource_attribute_def_def_projectDataQuota extends GroupResourceAttributesModuleAbstract implements GroupResourceAttributesModuleImplApi { @Override public void checkAttributeSyntax(PerunSessionImpl perunSession, Group group, Resource resource, Attribute attribute) throws WrongAttributeValueException { if(attribute.getValue() != null) { Matcher testMatcher = testingPattern.matcher((String) attribute.getValue()); if(!testMatcher.find()) throw new WrongAttributeValueException(attribute, resource, group, "Format of quota must be something like ex.: 1.30M or 2500K, but it is " + attribute.getValue()); } BigDecimal quotaNumber = ModulesUtilsBlImpl.getNumberAndUnitFromString(attribute.valueAsString()).getLeft(); if (quotaNumber.compareTo(BigDecimal.valueOf(0)) < 0) { throw new WrongAttributeValueException(attribute, attribute + " can't be less than 0."); } }  @Override void checkAttributeSyntax(PerunSessionImpl perunSession, Group group, Resource resource, Attribute attribute); @Override void checkAttributeSemantics(PerunSessionImpl perunSession, Group group, Resource resource, Attribute attribute); @Override List<String> getDependencies(); @Override AttributeDefinition getAttributeDefinition();  }
@Test(expected = WrongAttributeValueException.class) public void testWrongValue() throws Exception { System.out.println("testWrongValue()"); attributeToCheck.setValue("0"); classInstance.checkAttributeSyntax(sess, group, resource, attributeToCheck); }
@Test public void testCorrectSyntax() throws Exception { System.out.println("testCorrectSyntax()"); attributeToCheck.setValue("1T"); classInstance.checkAttributeSyntax(sess, group, resource, attributeToCheck); }