Package org.fao.geonet.domain.statistic

Examples of org.fao.geonet.domain.statistic.SearchRequest


    @Test
    public void testHasService() throws Exception {
        _requestRepo.save(SearchRequestRepositoryTest.newSearchRequest(_inc));

        SearchRequest request1 = SearchRequestRepositoryTest.newSearchRequest(_inc);
        final String expectedService = "ExpectedService";
        request1.setService(expectedService);
        while (request1.getParams().size() > 1) {
            request1.getParams().remove(0);
        }
        assertEquals(1, request1.getParams().size());
        request1 = _requestRepo.save(request1);

        final List<SearchRequestParam> all = _paramRepo.findAll(SearchRequestParamSpecs.hasService(expectedService));

        assertEquals(1, all.size());

        assertEquals(request1.getParams().get(0).getId(), all.get(0).getId());
    }
View Full Code Here


        assertEquals(0, outOfRangeInterval.size());
    }

    @Test
    public void testGetRequestDateToRequestCountBetweenByMonth() {
        SearchRequest searchRequest1 = newSearchRequest();
        searchRequest1.setRequestDate(new ISODate("1980-10-10"));
        searchRequest1 = _requestRepo.save(searchRequest1);

        SearchRequest searchRequest2 = newSearchRequest();
        searchRequest2.setRequestDate(new ISODate("1980-10-10T01:11:00"));
        _requestRepo.save(searchRequest2);

        SearchRequest searchRequest3 = newSearchRequest();
        searchRequest3.setRequestDate(new ISODate("1980-11-13T01:11:00"));
        searchRequest3 = _requestRepo.save(searchRequest3);

        SearchRequest searchRequest4 = newSearchRequest();
        searchRequest4.setRequestDate(new ISODate("1980-12-16T01:11:00"));
        searchRequest4 = _requestRepo.save(searchRequest4);

        final List<Pair<DateInterval.Month, Integer>> fullInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Month(), searchRequest1.getRequestDate(), searchRequest4.getRequestDate());
        assertEquals(3, fullInterval.size());
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Month(searchRequest1.getRequestDate()), 2)));
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Month(searchRequest3.getRequestDate()), 1)));
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Month(searchRequest4.getRequestDate()), 1)));


        final List<Pair<DateInterval.Month, Integer>> shortInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Month(), searchRequest3.getRequestDate(), searchRequest4.getRequestDate());
        assertEquals(2, shortInterval.size());
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Month(searchRequest3.getRequestDate()), 1)));
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Month(searchRequest4.getRequestDate()), 1)));

        final List<Pair<DateInterval.Month, Integer>> outOfRangeInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Month(), new ISODate("1990-01-01"), new ISODate("1990-01-02"));
        assertEquals(0, outOfRangeInterval.size());
    }
View Full Code Here

        assertEquals(0, outOfRangeInterval.size());
    }

    @Test
    public void testGetRequestDateToRequestCountBetweenByYear() {
        SearchRequest searchRequest1 = newSearchRequest();
        searchRequest1.setRequestDate(new ISODate("1980-10-10"));
        searchRequest1 = _requestRepo.save(searchRequest1);

        SearchRequest searchRequest2 = newSearchRequest();
        searchRequest2.setRequestDate(new ISODate("1980-10-10T01:11:00"));
        _requestRepo.save(searchRequest2);

        SearchRequest searchRequest3 = newSearchRequest();
        searchRequest3.setRequestDate(new ISODate("1981-11-13T01:11:00"));
        searchRequest3 = _requestRepo.save(searchRequest3);

        SearchRequest searchRequest4 = newSearchRequest();
        searchRequest4.setRequestDate(new ISODate("1982-12-16T01:11:00"));
        searchRequest4 = _requestRepo.save(searchRequest4);

        final List<Pair<DateInterval.Year, Integer>> fullInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Year(), searchRequest1.getRequestDate(), searchRequest4.getRequestDate());
        assertEquals(3, fullInterval.size());
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Year(searchRequest1.getRequestDate()), 2)));
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Year(searchRequest3.getRequestDate()), 1)));
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Year(searchRequest4.getRequestDate()), 1)));


        final List<Pair<DateInterval.Year, Integer>> shortInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Year(), searchRequest3.getRequestDate(), searchRequest4.getRequestDate());
        assertEquals(2, shortInterval.size());
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Year(searchRequest3.getRequestDate()), 1)));
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Year(searchRequest4.getRequestDate()), 1)));

        final List<Pair<DateInterval.Year, Integer>> outOfRangeInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Year(), new ISODate("1990-01-01"), new ISODate("1990-01-02"));
        assertEquals(0, outOfRangeInterval.size());
    }
View Full Code Here

        assertEquals(0, outOfRangeInterval.size());
    }

    @Test
    public void testGetMostRecentRequestDate() {
        SearchRequest searchRequest1 = newSearchRequest();
        searchRequest1.setRequestDate(new ISODate("1980-10-10T01:01:01"));
        _requestRepo.save(searchRequest1);

        SearchRequest searchRequest2 = newSearchRequest();
        searchRequest2.setRequestDate(new ISODate("1980-10-10T01:11:00"));
        _requestRepo.save(searchRequest2);

        SearchRequest searchRequest3 = newSearchRequest();
        searchRequest3.setRequestDate(new ISODate("1981-11-13T01:11:00"));
        _requestRepo.save(searchRequest3);

        SearchRequest searchRequest4 = newSearchRequest();
        searchRequest4.setRequestDate(new ISODate("1982-12-16T01:11:00"));
        searchRequest4 = _requestRepo.save(searchRequest4);

        assertEquals(searchRequest4.getRequestDate(), _requestRepo.getMostRecentRequestDate());
    }
View Full Code Here

        assertEquals(searchRequest4.getRequestDate(), _requestRepo.getMostRecentRequestDate());
    }

    @Test
    public void testGetOldestRequestDate() {
        SearchRequest searchRequest1 = newSearchRequest();
        searchRequest1.setRequestDate(new ISODate("1980-10-10T01:01:01"));
        searchRequest1 = _requestRepo.save(searchRequest1);

        SearchRequest searchRequest2 = newSearchRequest();
        searchRequest2.setRequestDate(new ISODate("1980-10-10T01:11:00"));
        _requestRepo.save(searchRequest2);

        SearchRequest searchRequest3 = newSearchRequest();
        searchRequest3.setRequestDate(new ISODate("1981-11-13T01:11:00"));
        _requestRepo.save(searchRequest3);

        SearchRequest searchRequest4 = newSearchRequest();
        searchRequest4.setRequestDate(new ISODate("1982-12-16T01:11:00"));
        _requestRepo.save(searchRequest4);

        assertEquals(searchRequest1.getRequestDate(), _requestRepo.getOldestRequestDate());
    }
View Full Code Here

        return newSearchRequest(inc);
    }

    public static SearchRequest newSearchRequest(AtomicInteger inc) {
        int val = inc.incrementAndGet();
        SearchRequest searchRequest = new SearchRequest();
        searchRequest.setSpatialFilter("spatialRequest" + val);
        searchRequest.setSortBy("sortby" + val);
        searchRequest.setSimple(val % 2 == 0);
        searchRequest.setService("service" + val);
        searchRequest.setAutogenerated(val % 2 == 1);
        searchRequest.setHits(val);
        searchRequest.setIpAddress("ip" + val);
        searchRequest.setLang("l" + val);
        searchRequest.setLuceneQuery("query" + val);
        searchRequest.setMetadataType("mdtype" + val);
        searchRequest.setRequestDate(new ISODate());
        searchRequest.addParam(SearchRequestParamRepositoryTest.newRequestParam(inc));
        searchRequest.addParam(SearchRequestParamRepositoryTest.newRequestParam(inc));

        return searchRequest;
    }
View Full Code Here

    @PersistenceContext
    EntityManager _entityManager;

    @Test
    public void testFindOne() throws Exception {
        SearchRequest searchRequest1 = newSearchRequest();
        assertTrue(searchRequest1.getParams().size() > 0);
        searchRequest1 = _requestRepo.save(searchRequest1);

        SearchRequest searchRequest2 = newSearchRequest();
        assertTrue(searchRequest2.getParams().size() > 0);
        searchRequest2 = _requestRepo.save(searchRequest2);

        _entityManager.flush();
        _entityManager.clear();

        SearchRequest found = _requestRepo.findOne(searchRequest2.getId());
        assertSameContents(searchRequest2, found);
        assertEquals(searchRequest2.getParams().size(), found.getParams().size());
        List<SearchRequestParam> params = _paramRepo.findAll(SearchRequestParamSpecs.hasService(searchRequest2.getService()));
        assertEquals(searchRequest2.getParams().size(), params.size());
    }
View Full Code Here

        assertEquals(searchRequest2.getParams().size(), params.size());
    }

    @Test
    public void testSelectAllDistinctAttributes() {
        SearchRequest searchRequest1 = newSearchRequest();
        searchRequest1.setRequestDate(new ISODate("1980-10-10T00:00:00"));
        searchRequest1 = _requestRepo.save(searchRequest1);

        SearchRequest searchRequest2 = newSearchRequest();
        searchRequest2.setRequestDate(new ISODate("1980-10-10T01:11:00"));
        _requestRepo.save(searchRequest2);

        SearchRequest searchRequest3 = newSearchRequest();
        searchRequest3.setRequestDate(new ISODate("1980-10-13T01:11:00"));
        _requestRepo.save(searchRequest3);

        SearchRequest searchRequest4 = newSearchRequest();
        searchRequest4.setRequestDate(new ISODate("1980-10-10T01:11:00"));
        _requestRepo.save(searchRequest4);

        final List<ISODate> isoDates = _requestRepo.selectAllDistinctAttributes(SearchRequest_.requestDate);

        assertEquals(3, isoDates.size());
View Full Code Here

    }

    @Test
    public void testGetSummary() {
        SearchRequest searchRequest1 = newSearchRequest();
        searchRequest1.setRequestDate(new ISODate("1980-10-10T00:00:00"));
        searchRequest1.setSimple(true);
        searchRequest1 = _requestRepo.save(searchRequest1);

        SearchRequest searchRequest2 = newSearchRequest();
        searchRequest2.setRequestDate(new ISODate("1980-10-10T01:11:00"));
        searchRequest2.setSimple(false);
        _requestRepo.save(searchRequest2);

        SearchRequest searchRequest3 = newSearchRequest();
        searchRequest3.setRequestDate(new ISODate("1980-10-13T01:11:00"));
        searchRequest3.setSimple(true);
        _requestRepo.save(searchRequest3);

        SearchRequest searchRequest4 = newSearchRequest();
        searchRequest4.setRequestDate(new ISODate("1980-11-16T01:11:00"));
        searchRequest4.setSimple(true);
        _requestRepo.save(searchRequest4);

        PathSpec<SearchRequest, Boolean> path = new PathSpec<SearchRequest, Boolean>() {
            @Override
            public Path<Boolean> getPath(Root<SearchRequest> root) {
View Full Code Here

        }
    }

    @Test
    public void testGetRequestDateToRequestCountBetweenByDayWithSpec() {
        SearchRequest searchRequest1 = newSearchRequest();
        searchRequest1.setRequestDate(new ISODate("1980-10-10"));
        searchRequest1 = _requestRepo.save(searchRequest1);

        SearchRequest searchRequest2 = newSearchRequest();
        searchRequest2.setRequestDate(new ISODate("1980-10-10T01:11:00"));
        _requestRepo.save(searchRequest2);

        SearchRequest searchRequest3 = newSearchRequest();
        searchRequest3.setRequestDate(new ISODate("1980-11-13T01:11:00"));
        searchRequest3 = _requestRepo.save(searchRequest3);

        SearchRequest searchRequest4 = newSearchRequest();
        searchRequest4.setRequestDate(new ISODate("1980-11-16T01:11:00"));
        searchRequest4 = _requestRepo.save(searchRequest4);

        final List<Pair<DateInterval.Day, Integer>> fullInterval = _requestRepo.getRequestDateToRequestCountBetween
                (new DateInterval.Day(), searchRequest1.getRequestDate(), searchRequest4.getRequestDate(),
                        SearchRequestSpecs.hasService(searchRequest1.getService()));
        assertEquals(1, fullInterval.size());
        assertTrue(fullInterval.contains(Pair.read(new DateInterval.Day(searchRequest1.getRequestDate()), 1)));
    }
View Full Code Here

TOP

Related Classes of org.fao.geonet.domain.statistic.SearchRequest

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.