Package org.jasig.portal.concurrency

Examples of org.jasig.portal.concurrency.CallableWithoutResult


           
            for (final EntityType<?> entityType : entityTypes) {
                final String entityClassName = entityType.getBindableJavaType().getName();
               
                try {
                    this.executeInTransaction(new CallableWithoutResult() {
                        @Override
                        protected void callWithoutResult() {
                            logger.trace("Purging all: " + entityClassName);
                           
                            final Query query = entityManager.createQuery("SELECT e FROM " + entityClassName + " AS e");
View Full Code Here


                return aggrs;
            }
        });
       
        //Verify aggregations were created
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregationIntervalInfo fiveMinuteInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.FIVE_MINUTE, instant);
                final AggregationIntervalInfo hourInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.HOUR, instant);
               
                final Map<K, T> fiveMinGroup = getAggregationDao().getAggregationsForInterval(
                        fiveMinuteInfo.getDateDimension(),
                        fiveMinuteInfo.getTimeDimension(),
                        fiveMinuteInfo.getAggregationInterval());
               
                final Map<K, T> hourGroup = getAggregationDao().getAggregationsForInterval(
                        hourInfo.getDateDimension(),
                        hourInfo.getTimeDimension(),
                        hourInfo.getAggregationInterval());
               
                final Map<K, T> foundAggrs = new HashMap<K, T>(fiveMinGroup);
                foundAggrs.putAll(hourGroup);
               
                assertEquals("Aggregations not created as expected", createdAggrs, foundAggrs);
            }
        });

        //Update Aggregations
        final Map<K, T> updatedAggrs = this.executeInTransaction(new Callable<Map<K, T>>() {
            @Override
            public Map<K, T> call() throws Exception {
                final Random r = new Random(0);
               
                final AggregationIntervalInfo fiveMinuteInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.FIVE_MINUTE, instant);
                final AggregationIntervalInfo hourInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.HOUR, instant);
               
                final Map<K, T> fiveMinGroup = getAggregationDao().getAggregationsForInterval(
                        fiveMinuteInfo.getDateDimension(),
                        fiveMinuteInfo.getTimeDimension(),
                        fiveMinuteInfo.getAggregationInterval());
               
                final Map<K, T> hourGroup = getAggregationDao().getAggregationsForInterval(
                        hourInfo.getDateDimension(),
                        hourInfo.getTimeDimension(),
                        hourInfo.getAggregationInterval());
               
                final Map<K, T> updatedAggrs = new HashMap<K, T>();
               
                for (final Entry<K, T> aggrEntry : fiveMinGroup.entrySet()) {
                    final T aggr = aggrEntry.getValue();
                    updateAggregation(fiveMinuteInfo, aggr, r);
                    getAggregationDao().updateAggregation(aggr);
                    updatedAggrs.put(aggrEntry.getKey(), aggr);
                }
                for (final Entry<K, T> aggrEntry : hourGroup.entrySet()) {
                    final T aggr = aggrEntry.getValue();
                    updateAggregation(hourInfo, aggr, r);
                    getAggregationDao().updateAggregation(aggr);
                    updatedAggrs.put(aggrEntry.getKey(), aggr);
                }
               
                return updatedAggrs;
            }
        });
       
        //Verify aggregations were updated
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregationIntervalInfo fiveMinuteInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.FIVE_MINUTE, instant);
                final AggregationIntervalInfo hourInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.HOUR, instant);
               
                final Map<K, T> fiveMinGroup = getAggregationDao().getAggregationsForInterval(
                        fiveMinuteInfo.getDateDimension(),
                        fiveMinuteInfo.getTimeDimension(),
                        fiveMinuteInfo.getAggregationInterval());
               
                final Map<K, T> hourGroup = getAggregationDao().getAggregationsForInterval(
                        hourInfo.getDateDimension(),
                        hourInfo.getTimeDimension(),
                        hourInfo.getAggregationInterval());
               
                final Map<K, T> foundAggrs = new HashMap<K, T>(fiveMinGroup);
                foundAggrs.putAll(hourGroup);
               
                assertEquals("Aggregations not updated as expected", updatedAggrs, foundAggrs);
            }
        });

        //Complete intervals
        final Map<K, T> completeAggrs = this.executeInTransaction(new Callable<Map<K, T>>() {
            @Override
            public Map<K, T> call() throws Exception {
                final AggregationIntervalInfo fiveMinuteInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.FIVE_MINUTE, instant);
                final AggregationIntervalInfo hourInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.HOUR, instant);
               
                final Map<K, T> fiveMinGroup = getAggregationDao().getAggregationsForInterval(
                        fiveMinuteInfo.getDateDimension(),
                        fiveMinuteInfo.getTimeDimension(),
                        fiveMinuteInfo.getAggregationInterval());
               
                final Map<K, T> hourGroup = getAggregationDao().getAggregationsForInterval(
                        hourInfo.getDateDimension(),
                        hourInfo.getTimeDimension(),
                        hourInfo.getAggregationInterval());
               
                final Map<K, T> completeAggrs = new HashMap<K, T>();
               
                for (final Entry<K, T> aggrEntry : fiveMinGroup.entrySet()) {
                    final T aggr = aggrEntry.getValue();
                    aggr.intervalComplete(5);
                    getAggregationDao().updateAggregation(aggr);
                    completeAggrs.put(aggrEntry.getKey(), aggr);
                }
                for (final Entry<K, T> aggrEntry : hourGroup.entrySet()) {
                    final T aggr = aggrEntry.getValue();
                    aggr.intervalComplete(60);
                    getAggregationDao().updateAggregation(aggr);
                    completeAggrs.put(aggrEntry.getKey(), aggr);
                }
               
                return completeAggrs;
            }
        });
       
        //Verify aggregations were completed
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregationIntervalInfo fiveMinuteInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.FIVE_MINUTE, instant);
                final AggregationIntervalInfo hourInfo = aggregationIntervalHelper.getIntervalInfo(AggregationInterval.HOUR, instant);
               
View Full Code Here

        final AggregationInterval interval = AggregationInterval.FIVE_MINUTE;
       
        final MutableObject startObj = new MutableObject();
        final MutableObject endObj = new MutableObject();
       
        this.executeInTransaction(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final Random r = new Random(0);
               
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                populateDateTimeDimensions(start, end, new FunctionWithoutResult<Tuple<DateDimension, TimeDimension>>() {
                    @Override
                    protected void applyWithoutResult(Tuple<DateDimension, TimeDimension> input) {
                        final TimeDimension td = input.second;
                        final DateDimension dd = input.first;
                        final DateTime instant = td.getTime().toDateTime(dd.getDate());
                       
                        if (startObj.getValue() == null) {
                            startObj.setValue(instant);
                        }
                        endObj.setValue(instant);
                       
                        if (instant.equals(interval.determineStart(instant))) {
                            final AggregationIntervalInfo intervalInfo = aggregationIntervalHelper.getIntervalInfo(interval, instant);
                           
                            final T baseAggregationA = getAggregationDao().createAggregation(createAggregationKey(intervalInfo, groupA));
                            final T baseAggregationB = getAggregationDao().createAggregation(createAggregationKey(intervalInfo, groupB));
                            
                            for (int u = 0; u < r.nextInt(50); u++) {
                                updateAggregation(intervalInfo, baseAggregationA, r);
                                updateAggregation(intervalInfo, baseAggregationB, r);
                            }
                           
                            baseAggregationA.intervalComplete(5);
                            baseAggregationB.intervalComplete(5);
                           
                            getAggregationDao().updateAggregation(baseAggregationA);
                            getAggregationDao().updateAggregation(baseAggregationB);
                           
                            aggrs.add(2);
                        }
                    }
                });
            }
        });
       
        //Verify all aggrs created
        assertEquals(1152, aggrs.intValue());
       


        //Find aggrs for one day
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                final DateTime queryStart = start.toDateMidnight().toDateTime();
                final DateTime queryEnd = queryStart.plusDays(1).minusSeconds(1);
               
                final List<T> baseAggregations =
                        getAggregationDao().getAggregations(queryStart, queryEnd, createAggregationKey(interval, groupA), groupB);
               
                assertEquals(158, baseAggregations.size());
            }
        });
       
      //Find aggrs for second day
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                final DateTime queryStart = start.toDateMidnight().minusDays(1).toDateTime();
                final DateTime queryEnd = queryStart.plusDays(2).minusSeconds(1);
               
                final List<T> baseAggregations =
                        getAggregationDao().getAggregations(queryStart, queryEnd, createAggregationKey(interval, groupA), groupB);
               
                assertEquals(158, baseAggregations.size());
            }
        });

        //Find all aggrs
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                final List<T> baseAggregations =
                        getAggregationDao().getAggregations(start, end.plusDays(1), createAggregationKey(interval, groupA), groupB);
               
                assertEquals(1152, baseAggregations.size());
            }
        });

        //Find first days worth
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                final List<T> baseAggregations =
                        getAggregationDao().getAggregations(start, end, createAggregationKey(interval, groupA), groupB);
               
                assertEquals(1152, baseAggregations.size());
            }
        });

        //Find second days worth
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                final List<T> baseAggregations =
                        getAggregationDao().getAggregations(start.plusDays(1), end.plusDays(1), createAggregationKey(interval, groupA), groupB);
               
                assertEquals(576, baseAggregations.size());
            }
        });

        //Find first 12 hours worth
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                final List<T> baseAggregations =
                        getAggregationDao().getAggregations(start, start.plusHours(12), createAggregationKey(interval, groupA), groupB);
               
                assertEquals(288, baseAggregations.size());
            }
        });

        //Find middle 24 hours worth
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                final List<T> baseAggregations =
                        getAggregationDao().getAggregations(start.plusHours(12), end.plusHours(12), createAggregationKey(interval, groupA), groupB);
               
                assertEquals(864, baseAggregations.size());
            }
        });

        //Find middle 24 hours worth for one group
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
               
                final List<T> baseAggregations =
                        getAggregationDao().getAggregations(start.plusHours(12), end.plusHours(12), createAggregationKey(interval, groupA));
               
                assertEquals(432, baseAggregations.size());
            }
        });

        //Find last 12 hours worth
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                final List<T> baseAggregations =
                        getAggregationDao().getAggregations(start.plusHours(36), end.plusDays(1), createAggregationKey(interval, groupA), groupB);
               
                assertEquals(288, baseAggregations.size());
            }
        });
       
        //TODO Query for intervals that are stored
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final Set<AggregatedGroupMapping> aggregatedGroupMappings = getAggregationDao().getAggregatedGroupMappings();
                assertEquals(2, aggregatedGroupMappings.size());
               
View Full Code Here

        final AggregationInterval interval = AggregationInterval.FIVE_MINUTE;
       
        final MutableObject startObj = new MutableObject();
        final MutableObject endObj = new MutableObject();
       
        this.executeInTransaction(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final Random r = new Random(0);
               
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
               
                populateDateTimeDimensions(start, end, new FunctionWithoutResult<Tuple<DateDimension, TimeDimension>>() {
                    @Override
                    protected void applyWithoutResult(Tuple<DateDimension, TimeDimension> input) {
                        final TimeDimension td = input.second;
                        final DateDimension dd = input.first;
                        final DateTime instant = td.getTime().toDateTime(dd.getDate());
                       
                        if (startObj.getValue() == null) {
                            startObj.setValue(instant);
                        }
                        endObj.setValue(instant);
                       
                        if (instant.equals(interval.determineStart(instant))) {
                            final AggregationIntervalInfo intervalInfo = aggregationIntervalHelper.getIntervalInfo(interval, instant);
                           
                            final T baseAggregationA = getAggregationDao().createAggregation(createAggregationKey(intervalInfo, groupA));
                            
                            for (int u = 0; u < r.nextInt(50); u++) {
                                updateAggregation(intervalInfo, baseAggregationA, r);
                            }
                            
                            baseAggregationA.intervalComplete(5);
                            
                            getAggregationDao().updateAggregation(baseAggregationA);
                            
                            aggrs.add(1);
                        }
                    }
                });
            }
        });
       
        //Verify all aggrs created
        assertEquals(2, aggrs.intValue());

        //Find unclosed 1 aggr
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final Random r = new Random(0);
               
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
View Full Code Here

        final AggregationInterval interval = AggregationInterval.FIVE_MINUTE;
       
        final MutableObject startObj = new MutableObject();
        final MutableObject endObj = new MutableObject();
       
        this.executeInTransaction(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final Random r = new Random(0);
               
                final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
                final AggregatedGroupMapping groupB = aggregatedGroupLookupDao.getGroupMapping("local.1");
               
                populateDateTimeDimensions(start, end, new FunctionWithoutResult<Tuple<DateDimension, TimeDimension>>() {
                    @Override
                    protected void applyWithoutResult(Tuple<DateDimension, TimeDimension> input) {
                        final TimeDimension td = input.second;
                        final DateDimension dd = input.first;
                        final DateTime instant = td.getTime().toDateTime(dd.getDate());
                       
                        if (startObj.getValue() == null) {
                            startObj.setValue(instant);
                        }
                        endObj.setValue(instant);
                       
                        if (instant.equals(interval.determineStart(instant))) {
                            final AggregationIntervalInfo intervalInfo = aggregationIntervalHelper.getIntervalInfo(interval, instant);
                           
                            final T baseAggregationA = getAggregationDao().createAggregation(createAggregationKey(intervalInfo, groupA));
                            final T baseAggregationB = getAggregationDao().createAggregation(createAggregationKey(intervalInfo, groupB));
                            
                            for (int u = 0; u < r.nextInt(50); u++) {
                                updateAggregation(intervalInfo, baseAggregationA, r);
                                updateAggregation(intervalInfo, baseAggregationB, r);
                            }
                            
                            if (aggrs.intValue() % 4 == 0) {
                                baseAggregationA.intervalComplete(5);
                            }
                            baseAggregationB.intervalComplete(5);
                            
                            getAggregationDao().updateAggregation(baseAggregationA);
                            getAggregationDao().updateAggregation(baseAggregationB);
                            
                            aggrs.add(2);
                        }
                    }
                });
            }
        });
       
        //Verify all aggrs created
        assertEquals(4, aggrs.intValue());

        //Find unclosed 1 aggr
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final Collection<T> baseAggregations = getAggregationDao()
                        .getUnclosedAggregations(start.minusDays(1), end.plusDays(1), interval);
               
                assertEquals(1, baseAggregations.size());
               
                for (final T baseAggregationImpl : baseAggregations) {
                    baseAggregationImpl.intervalComplete(5);
                    getAggregationDao().updateAggregation(baseAggregationImpl);
                }
            }
        });

        //Find unclosed 0 aggr
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final Collection<T> baseAggregations = getAggregationDao()
                        .getUnclosedAggregations(start.minusDays(1), end.plusDays(1), interval);
               
View Full Code Here

    @Autowired
    private TimeDimensionDao timeDimensionDao;
   
  @Test
  public void testGetMinMaxDateDimension() {
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final DateDimension newestDateDimension = dateDimensionDao.getNewestDateDimension();
                assertNull(newestDateDimension);
            }
        });
       
       
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final List<DateDimension> dateDimensions = dateDimensionDao.getDateDimensions();
               
                assertEquals(Collections.EMPTY_LIST, dateDimensions);
            }
        });
       
       
        this.executeInTransaction(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                DateMidnight date = new DateMidnight(2012, 1, 1);
               
                for (int i = 0; i < 7; i++) {
                    dateDimensionDao.createDateDimension(date, 0, null);
                    date = date.plusDays(1);
                }
            }
        });
       
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                DateMidnight date = new DateMidnight(2012, 1, 1);
                final DateDimension dateDimension = dateDimensionDao.getDateDimensionByDate(date);
                assertNotNull(dateDimension);
            }
        });
       
       
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final List<DateDimension> dateDimensions = dateDimensionDao.getDateDimensions();
               
                assertEquals(7, dateDimensions.size());
            }
        });
       
       
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final DateMidnight start = new DateMidnight(2012, 1, 2);
                final DateMidnight end = new DateMidnight(2012, 1, 6);
                final List<DateDimension> dateDimensions = dateDimensionDao.getDateDimensionsBetween(start, end);
               
                assertEquals(4, dateDimensions.size());
            }
        });
       
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final DateDimension oldestDateDimension = dateDimensionDao.getOldestDateDimension();
               
                assertEquals(2012, oldestDateDimension.getYear());
                assertEquals(1, oldestDateDimension.getMonth());
                assertEquals(1, oldestDateDimension.getDay());
            }
        });
       
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final DateDimension newestDateDimension = dateDimensionDao.getNewestDateDimension();
               
                assertEquals(2012, newestDateDimension.getYear());
View Full Code Here

        final IEntityGroup everyoneGroup = mock(IEntityGroup.class);
        when(everyoneGroup.getServiceName()).thenReturn(new CompositeName("local"));
        when(everyoneGroup.getName()).thenReturn("Everyone");
        when(compositeGroupService.findGroup("local.0")).thenReturn(everyoneGroup);
       
      this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
                assertNotNull(defaultAggregatedGroupConfig);
                assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
                assertEquals(0, defaultAggregatedGroupConfig.getIncluded().size());
               
                AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
                assertNull(loginAggregatedGroupConfig);
                loginAggregatedGroupConfig = eventAggregationManagementDao.createAggregatedGroupConfig(LoginPortalEventAggregator.class);
                assertNotNull(loginAggregatedGroupConfig);
                assertEquals(0, loginAggregatedGroupConfig.getExcluded().size());
                assertEquals(0, loginAggregatedGroupConfig.getIncluded().size());
               
                final AggregatedGroupMapping group = aggregatedGroupLookupDao.getGroupMapping("local.0");
               
                defaultAggregatedGroupConfig.getIncluded().add(group);
                loginAggregatedGroupConfig.getExcluded().add(group);

                eventAggregationManagementDao.updateAggregatedGroupConfig(defaultAggregatedGroupConfig);
                eventAggregationManagementDao.updateAggregatedGroupConfig(loginAggregatedGroupConfig);
            }
        });
     
      this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
                assertNotNull(defaultAggregatedGroupConfig);
                assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
                assertEquals(1, defaultAggregatedGroupConfig.getIncluded().size());
               
                AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
                assertNotNull(loginAggregatedGroupConfig);
                assertEquals(1, loginAggregatedGroupConfig.getExcluded().size());
                assertEquals(0, loginAggregatedGroupConfig.getIncluded().size());
               
                eventAggregationManagementDao.deleteAggregatedGroupConfig(defaultAggregatedGroupConfig);
                eventAggregationManagementDao.deleteAggregatedGroupConfig(loginAggregatedGroupConfig);
            }
        });
     
      this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
                assertNotNull(defaultAggregatedGroupConfig);
                assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
View Full Code Here

        });
  }

    @Test
    public void testAggregatedIntervalConfig() throws Exception {
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedIntervalConfig defaultAggregatedIntervalConfig = eventAggregationManagementDao.getDefaultAggregatedIntervalConfig();
                assertNotNull(defaultAggregatedIntervalConfig);
                assertEquals(0, defaultAggregatedIntervalConfig.getExcluded().size());
                assertEquals(0, defaultAggregatedIntervalConfig.getIncluded().size());
               
                AggregatedIntervalConfig loginAggregatedIntervalConfig = eventAggregationManagementDao.getAggregatedIntervalConfig(LoginPortalEventAggregator.class);
                assertNull(loginAggregatedIntervalConfig);
                loginAggregatedIntervalConfig = eventAggregationManagementDao.createAggregatedIntervalConfig(LoginPortalEventAggregator.class);
                assertNotNull(loginAggregatedIntervalConfig);
                assertEquals(0, loginAggregatedIntervalConfig.getExcluded().size());
                assertEquals(0, loginAggregatedIntervalConfig.getIncluded().size());
               
                defaultAggregatedIntervalConfig.getIncluded().add(AggregationInterval.MINUTE);
                loginAggregatedIntervalConfig.getExcluded().add(AggregationInterval.MINUTE);

                eventAggregationManagementDao.updateAggregatedIntervalConfig(defaultAggregatedIntervalConfig);
                eventAggregationManagementDao.updateAggregatedIntervalConfig(loginAggregatedIntervalConfig);
            }
        });
       
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedIntervalConfig defaultAggregatedIntervalConfig = eventAggregationManagementDao.getDefaultAggregatedIntervalConfig();
                assertNotNull(defaultAggregatedIntervalConfig);
                assertEquals(0, defaultAggregatedIntervalConfig.getExcluded().size());
                assertEquals(1, defaultAggregatedIntervalConfig.getIncluded().size());
               
                AggregatedIntervalConfig loginAggregatedIntervalConfig = eventAggregationManagementDao.getAggregatedIntervalConfig(LoginPortalEventAggregator.class);
                assertNotNull(loginAggregatedIntervalConfig);
                assertEquals(1, loginAggregatedIntervalConfig.getExcluded().size());
                assertEquals(0, loginAggregatedIntervalConfig.getIncluded().size());
               
                eventAggregationManagementDao.deleteAggregatedIntervalConfig(defaultAggregatedIntervalConfig);
                eventAggregationManagementDao.deleteAggregatedIntervalConfig(loginAggregatedIntervalConfig);
            }
        });
       
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final AggregatedIntervalConfig defaultAggregatedIntervalConfig = eventAggregationManagementDao.getDefaultAggregatedIntervalConfig();
                assertNotNull(defaultAggregatedIntervalConfig);
                assertEquals(0, defaultAggregatedIntervalConfig.getExcluded().size());
View Full Code Here

        });
    }
   
    @Test
    public void testQuarterDetails() throws Exception {
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final List<QuarterDetail> quartersDetails = eventAggregationManagementDao.getQuartersDetails();
                EventDateTimeUtils.validateQuarters(quartersDetails);
               
View Full Code Here

        });
    }
   
    @Test
    public void testAcademicTermDetails() throws Exception {
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final List<AcademicTermDetail> academicTermDetail = eventAggregationManagementDao.getAcademicTermDetails();
                assertEquals(0, academicTermDetail.size());
               
                List<AcademicTermDetail> academicTermDetails = new ArrayList<AcademicTermDetail>();
               
                academicTermDetails.add(new AcademicTermDetailImpl(new DateMidnight(2012, 1, 1), new DateMidnight(2012, 6, 1), "Spring 2012"));
                academicTermDetails.add(new AcademicTermDetailImpl(new DateMidnight(2012, 6, 1), new DateMidnight(2012, 9, 1), "Summer 2012"));
                academicTermDetails.add(new AcademicTermDetailImpl(new DateMidnight(2012, 9, 1), new DateMidnight(2013, 1, 1), "Fall 2012"));
               
               
                eventAggregationManagementDao.setAcademicTermDetails(academicTermDetails);
            }
        });

        try {
            this.executeInTransaction(new CallableWithoutResult() {
                @Override
                protected void callWithoutResult() {
                    final List<AcademicTermDetail> academicTermDetail = eventAggregationManagementDao.getAcademicTermDetails();
                    assertEquals(3, academicTermDetail.size());
                   
                    academicTermDetail.add(new AcademicTermDetailImpl(new DateMidnight(2012, 1, 1), new DateMidnight(2013, 6, 1), "Spring 2013"));
                   
                    try {
                        eventAggregationManagementDao.setAcademicTermDetails(academicTermDetail);
                        fail();
                    }
                    catch (IllegalArgumentException e) {
                        //expected
                    }
                }
            });
           
            fail();
        }
        catch (TransactionSystemException e) {
            //Expected
        }
                   
                   
        this.executeInTransaction(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final List<AcademicTermDetail> academicTermDetail = eventAggregationManagementDao.getAcademicTermDetails();
                assertEquals(3, academicTermDetail.size());
               
               
                academicTermDetail.get(0).setTermName("New Term");
                academicTermDetail.remove(2);
               
                eventAggregationManagementDao.setAcademicTermDetails(academicTermDetail);
            }
        });
       

       
        this.execute(new CallableWithoutResult() {
            @Override
            protected void callWithoutResult() {
                final List<AcademicTermDetail> academicTermDetail = eventAggregationManagementDao.getAcademicTermDetails();
                assertEquals(2, academicTermDetail.size());
            }
View Full Code Here

TOP

Related Classes of org.jasig.portal.concurrency.CallableWithoutResult

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.