Package org.rhq.core.domain.configuration.definition.constraint

Examples of org.rhq.core.domain.configuration.definition.constraint.FloatRangeConstraint


                    Double floatMin = (floatDetails.getMinimum() != null) ? new Double(floatDetails.getMinimum()
                        .toString()) : null;
                    Double floatMax = (floatDetails.getMaximum() != null) ? new Double(floatDetails.getMaximum()
                        .toString()) : null;

                    FloatRangeConstraint fc = new FloatRangeConstraint(floatMin, floatMax);
                    toConstraints.add(fc);
                } else if (constraint instanceof IntegerConstraintType) {
                    IntegerConstraintType intDetails = (IntegerConstraintType) constraint;

                    Long longMin = (intDetails.getMinimum() != null) ? new Long(intDetails.getMinimum().toString())
View Full Code Here


                longRangeValidator.setMaximum(maxValue);
            }

            validator = longRangeValidator;
        } else if (constraint instanceof FloatRangeConstraint) {
            FloatRangeConstraint floatRangeConstraint = (FloatRangeConstraint) constraint;
            DoubleRangeValidator doubleRangeValidator = new DoubleRangeValidator();
            Double minValue = floatRangeConstraint.getMinimum();
            if (minValue != null) {
                doubleRangeValidator.setMinimum(minValue);
            }

            Double maxValue = floatRangeConstraint.getMaximum();
            if (maxValue != null) {
                doubleRangeValidator.setMaximum(maxValue);
            }

            validator = doubleRangeValidator;
View Full Code Here

                        validator.setMax(Integer.MAX_VALUE);
                    }

                    validators.add(validator);
                } else if (constraint instanceof FloatRangeConstraint) {
                    FloatRangeConstraint floatConstraint = ((FloatRangeConstraint) constraint);
                    FloatRangeValidator validator = new FloatRangeValidator();
                    if (floatConstraint.getMinimum() != null) {
                        validator.setMin(floatConstraint.getMinimum().floatValue());
                    }
                    if (floatConstraint.getMaximum() != null) {
                        validator.setMax(floatConstraint.getMaximum().floatValue());
                    }
                    validators.add(validator);
                } else if (constraint instanceof RegexConstraint) {
                    RegExpValidator validator = new RegExpValidator("^" + constraint.getDetails() + "$");
                    validators.add(validator);
View Full Code Here

                if (co instanceof IntegerRangeConstraint) {
                    IntegerRangeConstraint irc = (IntegerRangeConstraint) co;
                    assert irc.getMinimum() == 5; // TODO change when JBNADM-1597 is being worked on
                    assert irc.getMaximum() == 0;
                } else if (co instanceof FloatRangeConstraint) {
                    FloatRangeConstraint frc = (FloatRangeConstraint) co;
                    assert frc != null;
                    assert frc.getMaximum() == 0.0; // TODO change when JBNADM-1597 is being worked on
                    assert frc.getMinimum() == 5.0;
                }
            }
            getTransactionManager().rollback();

        } finally {
View Full Code Here

                            // TODO (ips, 3/31/10): The below is a workaround for IntegerRangeConstraint.onLoad() not being called by Hibernate.
                            irc.setDetails(irc.getDetails());
                            assert irc.getMaximum() == 10;
                            assert irc.getMinimum() == -2;
                        } else if (constraint instanceof FloatRangeConstraint) {
                            FloatRangeConstraint frc = (FloatRangeConstraint) constraint;
                            assert frc != null : "Float-constraint was null, but should not be";
                            // See JBNADM-1596/97
                            assert frc.getDetails().equals("10.0#5.0");
                            // TODO (ips, 3/31/10): The below is a workaround for FloatRangeConstraint.onLoad() not being called by Hibernate.
                            frc.setDetails(frc.getDetails());
                            assert frc.getMinimum() == 10; // TODO change when JBNADM-1597 is being worked on
                            assert frc.getMaximum() == 5;

                        } else {
                            assert true == false : "Unknown constraint type encountered";
                        }
                    }
View Full Code Here

            ConfigurationDefinition def = new ConfigurationDefinition(TEST_CONFIG_CONSTRAINT_NAME, "test data");

            PropertyDefinitionSimple prop = new PropertyDefinitionSimple("ConstrainedProperty", "", true,
                PropertySimpleType.FLOAT);
            prop.addConstraints(new FloatRangeConstraint(1d, 3d));
            def.put(prop);
            em.persist(def);
            testReadConstraints(em);
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here

        bothRangeFound = false;

        for (Constraint c : simple.getConstraints()) {
            assert c instanceof FloatRangeConstraint : "serverProperty32 loaded with invalid constraint of class: "
                + c.getClass();
            FloatRangeConstraint fc = (FloatRangeConstraint) c;
            if ((fc.getMinimum() != null) && (fc.getMaximum() == null)) {
                assert fc.getMinimum().compareTo(new Double("0.5")) == 0 : "serverProperty32 minimum float range read incorrectly with no maximum range";
                noMaxRangeFound = true;
            } else if ((fc.getMinimum() == null) && (fc.getMaximum() != null)) {
                assert fc.getMaximum().compareTo(new Double("99.9")) == 0 : "serverProperty32 maximum float range read incorrectly with no minimum range";
                noMinRangeFound = true;
            } else if ((fc.getMinimum() != null) && (fc.getMaximum() != null)) {
                assert fc.getMinimum().compareTo(new Double("20.2")) == 0 : "serverProperty32 minimum float range read incorrectly with maximum range";
                assert fc.getMaximum().compareTo(new Double("80.8")) == 0 : "serverProperty32 maximum float range read incorrectly with minimum range";
                bothRangeFound = true;
            } else {
                assert false : "serverProperty32 loaded with unexpected float range";
            }
        }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.configuration.definition.constraint.FloatRangeConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.