Package org.openengsb.core.api.model

Examples of org.openengsb.core.api.model.QueryRequest


        assertWorking("query with one condition don't work", "a:\"b\"");
    }

    @Test
    public void testAndQueryRequestObjectConstruction_shouldBuildCorrectObjects() throws Exception {
        QueryRequest request = parser.parseQueryString("a:\"b\" and c:\"d\"");
        assertThat(request.isAndJoined(), is(true));
        assertThat(request.getParameter("a").contains("b"), is(true));
        assertThat(request.getParameter("c").contains("d"), is(true));
        request = parser.parseQueryString("a:\"b\" and c:\"d\" and e:\"f\"");
        assertThat(request.isAndJoined(), is(true));
        assertThat(request.getParameter("a").contains("b"), is(true));
        assertThat(request.getParameter("c").contains("d"), is(true));
        assertThat(request.getParameter("e").contains("f"), is(true));
    }
View Full Code Here


        assertThat(request.getParameter("e").contains("f"), is(true));
    }

    @Test
    public void testOrQueryRequestObjectConstruction_shouldBuildCorrectObjects() throws Exception {
        QueryRequest request = parser.parseQueryString("a:\"b\" or c:\"d\"");
        assertThat(request.isAndJoined(), is(false));
        assertThat(request.getParameter("a").contains("b"), is(true));
        assertThat(request.getParameter("c").contains("d"), is(true));
        request = parser.parseQueryString("a:\"b\" or c:\"d\" or e:\"f\"");
        assertThat(request.isAndJoined(), is(false));
        assertThat(request.getParameter("a").contains("b"), is(true));
        assertThat(request.getParameter("c").contains("d"), is(true));
        assertThat(request.getParameter("e").contains("f"), is(true));
    }
View Full Code Here

        assertThat(request.getParameter("e").contains("f"), is(true));
    }

    @Test
    public void testSpecialQueryRequestObjectConstruction_shouldBuildCorrectObjects() throws Exception {
        QueryRequest request = parser.parseQueryString("");
        assertThat(request.getParameters().size(), is(0));
        request = parser.parseQueryString("a:\"b\"");
        assertThat(request.getParameter("a").contains("b"), is(true));
    }
View Full Code Here

        EKBCommit commit =
            getTestEKBCommit().addInserts(
                Arrays.asList(model1.getModel(), model2.getModel(), model3.getModel(), model4.getModel()));
        persist.commit(commit);

        QueryRequest request =
            QueryRequest.create().orJoined().addParameter("name", "model1").addParameter("name", "model2")
                .addParameter("field", "test");
        List<Object> result = (List<Object>) query.query(getTestModel(), request);
        assertThat(result, notNullValue());
        assertThat(result.size(), is(3));
View Full Code Here

        model.setName("C:\\\\test");
        model.setEdbId("createevent/6");
        EKBCommit commit = getTestEKBCommit().addInsert(model.getModel());
        persist.commit(commit);

        QueryRequest request = QueryRequest.query("name", "C:\\\\test").wildcardUnaware();
        @SuppressWarnings("unchecked")
        List<Object> result = (List<Object>) query.query(getTestModel(), request);
        assertThat(result.isEmpty(), is(false));
        assertThat(result.get(0), is(getTestModel()));
    }
View Full Code Here

        model2.setName("testmodel");
        model2.setEdbId("createevent/8");
        commit = getTestEKBCommit().addInsert(model2.getModel());
        persist.commit(commit);

        QueryRequest request = QueryRequest.query("name", "testmodel");
        List<Object> result = (List<Object>) query.query(getTestModel(), request);
        assertThat(result.size(), is(2));
        request.setContextId(CONTEXT);
        result = (List<Object>) query.query(getTestModel(), request);
        assertThat(result.size(), is(1));
        assertThat(new TestModelDecorator(result.get(0)).getEdbId(), is("createevent/7"));
        request.setContextId("othercontext");
        result = (List<Object>) query.query(getTestModel(), request);
        assertThat(result.size(), is(1));
        assertThat(new TestModelDecorator(result.get(0)).getEdbId(), is("createevent/8"));
        request.setContextId("somenonesensecontext");
        result = (List<Object>) query.query(getTestModel(), request);
        assertThat(result.size(), is(0));
        ContextHolder.get().setCurrentContextId(CONTEXT);
    }
View Full Code Here

        UUID postCommit2Revision = query.getLastRevisionNumberOfContext(CONTEXT);
        persist.deleteCommit(postCommit2Revision, CONTEXT);

        UUID postDelete1Revision = query.getLastRevisionNumberOfContext(CONTEXT);
        assertThat(postDelete1Revision, is(preCommit2Revision));
        QueryRequest request = QueryRequest.query("edbId", "deleteCommitTest/1");
        List<Object> result = (List<Object>) query.query(getTestModel(), request);
        assertThat(result.size(), is(1));
        persist.deleteCommit(preCommit2Revision, CONTEXT);

        UUID postDelete2Revision = query.getLastRevisionNumberOfContext(CONTEXT);
View Full Code Here

        v1 = new EDBObject("/test/query2", data2);
        ci = getEDBCommit();
        ci.insert(v1);
        long time2 = db.commit(ci);

        QueryRequest req = QueryRequest.query("A", "B");
        List<EDBObject> list1 = db.query(req);
        req = QueryRequest.query("A", "B").addParameter("Dog", "Food");
        List<EDBObject> list2 = db.query(req);
        req = QueryRequest.query("Cow", "Milk");
        List<EDBObject> list3 = db.query(req);
View Full Code Here

        commit.insert(v2);
        commit.insert(v3);
        commit.insert(v4);
        commit.insert(v5);
        db.commit(commit);
        QueryRequest request = QueryRequest.create().orJoined();
        request.addParameter("Cow", "Milk");
        assertThat(db.query(request).size(), is(2));
        request.addParameter("Cow", "Steak");
        assertThat(db.query(request).size(), is(3));
        request.addParameter("Animal", "Dog");
        assertThat(db.query(request).size(), is(4));
        request.removeParameter("Cow");
        assertThat(db.query(request).size(), is(3));
        request.addParameter("Cow", "Milk").addParameter("House", "Garden");
        assertThat(db.query(request).size(), is(5));
    }
View Full Code Here

        EDBObject v4 = new EDBObject("/test2/query/15/4", data4);
        commit = getEDBCommit();
        commit.insert(v3);
        commit.insert(v4);
        db.commit(commit);
        QueryRequest request = QueryRequest.create().orJoined();
        request.addParameter("Animal", "Dog");
        assertThat(db.query(request).size(), is(2));
        request.setContextId("/test");
        List<EDBObject> result = db.query(request);
        assertThat(result.size(), is(1));
        assertThat(result.get(0).getOID(), is("/test/query/15/2"));

        request.setContextId("/test2");
        result = db.query(request);
        assertThat(result.size(), is(1));
        assertThat(result.get(0).getOID(), is("/test2/query/15/4"));
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.model.QueryRequest

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.