Examples of Constraint


Examples of org.jmock.Constraint

        assertTrue(p.eval(null));
        assertTrue(p.eval(new Object()));
    }

    public void testIsInstanceOf() {
        Constraint p = new IsInstanceOf(Number.class);
        assertTrue(p.eval(new Integer(1)));
        assertTrue(p.eval(new Double(1.0)));
        assertTrue(!p.eval("a string"));
        assertTrue(!p.eval(null));
    }
View Full Code Here

Examples of org.jmock.Constraint

        assertTrue(!p.eval("a string"));
        assertTrue(!p.eval(null));
    }

    public void testIsNot() {
        Constraint p = new IsNot(new True());
        assertTrue(!p.eval(null));
        assertTrue(!p.eval(new Object()));
    }
View Full Code Here

Examples of org.jmock.Constraint

    public void testIsEventFrom() {
        Object o = new Object();
        EventObject ev = new EventObject(o);
        EventObject ev2 = new EventObject(new Object());

        Constraint p = new IsEventFrom(o);

        assertTrue(p.eval(ev));
        assertTrue("p should eval to false for an event not from o",
                !p.eval(ev2));
        assertTrue("p should eval to false for objects that are not events",
                !p.eval(o));
    }
View Full Code Here

Examples of org.jmock.Constraint

        DerivedEvent good_ev = new DerivedEvent(o);
        DerivedEvent wrong_source = new DerivedEvent(new Object());
        EventObject wrong_type = new EventObject(o);
        EventObject wrong_source_and_type = new EventObject(new Object());

        Constraint p = new IsEventFrom(DerivedEvent.class, o);

        assertTrue(p.eval(good_ev));
        assertTrue("p should eval to false for an event not from o",
                !p.eval(wrong_source));
        assertTrue("p should eval to false for an event of the wrong type",
                !p.eval(wrong_type));
        assertTrue("p should eval to false for an event of the wrong type " +
                "and from the wrong source",
                !p.eval(wrong_source_and_type));
    }
View Full Code Here

Examples of org.jmock.Constraint

                "and from the wrong source",
                !p.eval(wrong_source_and_type));
    }

    public void testIsCloseTo() {
        Constraint p = new IsCloseTo(1.0, 0.5);

        assertTrue(p.eval(new Double(1.0)));
        assertTrue(p.eval(new Double(0.5)));
        assertTrue(p.eval(new Double(1.5)));

        assertTrue(p.eval(new Float(1.0)));
        assertTrue(p.eval(new Integer(1)));

        assertTrue("number too large", !p.eval(new Double(2.0)));
        assertTrue("number too small", !p.eval(new Double(0.0)));

        try {
            p.eval("wrong type");
            fail("ClassCastException expected for wrong type of argument");
        } catch (ClassCastException ex) {
            // expected
        }
    }
View Full Code Here

Examples of org.jmock.core.Constraint

        final long beforeTime = System.currentTimeMillis();

        Mock monitor = mock(ComponentMonitor.class);
        Constructor emptyHashMapCtor = HashMap.class.getConstructor(new Class[0]);
        monitor.expects(once()).method("instantiating").with(eq(emptyHashMapCtor));
        Constraint startIsAfterBegin = new Constraint() {
            public boolean eval(Object o) {
                Long startTime = (Long) o;
                return beforeTime <= startTime.longValue();
            }

            public StringBuffer describeTo(StringBuffer stringBuffer) {
                return stringBuffer.append("The startTime wasn't after the begin of the test");
            }
        };
        Constraint durationIsGreaterThanOrEqualToZero = new Constraint() {
            public boolean eval(Object o) {
                Long duration = (Long) o;
                return 0 <= duration.longValue();
            }
View Full Code Here

Examples of org.jquantlib.math.optimization.Constraint

        }

        final LevenbergMarquardt solver = new LevenbergMarquardt (ts.accuracy(), ts.accuracy(), ts.accuracy());

        final EndCriteria endCriteria = new EndCriteria (100, 10, 0.00, ts.accuracy(), 0.00);
        final Constraint solverConstraint = (forcePositive ? new PositiveConstraint() : new NoConstraint());
        int i = localisation -1;
        //FIXME, convexmonotone interpolation?
        final int dataAdjust = 1;

        for (; i < nInsts; ++ i) {
View Full Code Here

Examples of org.jresearch.flexess.core.model.uam.Constraint

    // Create permission with region attribute
    Permission permission = uamFactory.createPermission();
    permission.setName("TestPermission");
    EAttribute permRegionAttr = getRegionAttr();
    permission.getEStructuralFeatures().add(permRegionAttr);
    Constraint constraint = uamFactory.createConstraint();
    permission.setConstraint(constraint);
    constraint.setExpession(expression);
    model.getEClassifiers().add(permission);

    // Create protected object with region attribute
    PObject pObject = uamFactory.createPObject();
    pObject.setName("TestProtectedObject");
View Full Code Here

Examples of org.lealone.dbobject.constraint.Constraint

            if (table.isTemporary() && !table.isGlobalTemporary()) {
                session.removeLocalTempTableIndex(index);
                return;
            }
        } else if (type == DbObject.CONSTRAINT) {
            Constraint constraint = (Constraint) obj;
            Table table = constraint.getTable();
            if (table.isTemporary() && !table.isGlobalTemporary()) {
                session.removeLocalTempTableConstraint(constraint);
                return;
            }
        }
View Full Code Here

Examples of org.modeshape.jcr.query.model.Constraint

    }

    @Test
    public void shouldParseConstraintFromStringWithParenthesesAndConjunctionAndDisjunctions() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b') OR (ISSAMENODE('/c/d') AND ISSAMENODE('/e/f'))"),
                                                       typeSystem,
                                                       selector);
        assertThat(constraint, is(instanceOf(Or.class)));
        Or or = (Or)constraint;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.