org.apache.commons.collections4.functors.TruePredicate Java Examples
The following examples show how to use
org.apache.commons.collections4.functors.TruePredicate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FilterPredicateTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 5 votes |
@Test public void testGetPredicateWithAllValuesIsTruePredicate() { // setup when(settings.getSSIDs()).thenReturn(Collections.emptySet()); when(settings.getWiFiBands()).thenReturn(EnumUtils.values(WiFiBand.class)); when(settings.getStrengths()).thenReturn(EnumUtils.values(Strength.class)); when(settings.getSecurities()).thenReturn(EnumUtils.values(Security.class)); fixture = FilterPredicate.makeAccessPointsPredicate(settings); // execute Predicate<WiFiDetail> actual = ((FilterPredicate) fixture).getPredicate(); // validate assertTrue(actual instanceof TruePredicate); }
Example #2
Source File: EnumUtilsTest.java From WiFiAnalyzer with GNU General Public License v3.0 | 5 votes |
@Test public void testPredicateExpectsTruePredicateWithAllValues() { // setup Set<TestObject> inputs = EnumUtils.values(TestObject.class); // execute Predicate<TestObject> actual = EnumUtils.predicate(TestObject.class, inputs, new TestObjectTransformer()); // validate assertTrue(actual instanceof TruePredicate); }
Example #3
Source File: CentralAuthenticationServiceImplWithMockitoTests.java From springboot-shiro-cas-mybatis with MIT License | 4 votes |
@Test public void getTicketsWithNoPredicate() { final Collection<Ticket> c = this.cas.getTickets(TruePredicate.INSTANCE); assertEquals(c.size(), this.ticketRegMock.getTickets().size()); }
Example #4
Source File: StatisticsController.java From springboot-shiro-cas-mybatis with MIT License | 4 votes |
/** * Handles the request. * * @param httpServletRequest the http servlet request * @param httpServletResponse the http servlet response * @return the model and view * @throws Exception the exception */ @RequestMapping(method = RequestMethod.GET) protected ModelAndView handleRequestInternal(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) throws Exception { final ModelAndView modelAndView = new ModelAndView(MONITORING_VIEW_STATISTICS); modelAndView.addObject("startTime", this.upTimeStartDate); final double difference = System.currentTimeMillis() - this.upTimeStartDate.getTime(); modelAndView.addObject("upTime", calculateUptime(difference, new LinkedList<Integer>( Arrays.asList(NUMBER_OF_MILLISECONDS_IN_A_DAY, NUMBER_OF_MILLISECONDS_IN_AN_HOUR, NUMBER_OF_MILLISECONDS_IN_A_MINUTE, NUMBER_OF_MILLISECONDS_IN_A_SECOND, 1)), new LinkedList<String>(Arrays.asList("day", "hour", "minute", "second", "millisecond")))); modelAndView.addObject("totalMemory", convertToMegaBytes(Runtime.getRuntime().totalMemory())); modelAndView.addObject("maxMemory", convertToMegaBytes(Runtime.getRuntime().maxMemory())); modelAndView.addObject("freeMemory", convertToMegaBytes(Runtime.getRuntime().freeMemory())); modelAndView.addObject("availableProcessors", Runtime.getRuntime().availableProcessors()); modelAndView.addObject("serverHostName", httpServletRequest.getServerName()); modelAndView.addObject("serverIpAddress", httpServletRequest.getLocalAddr()); modelAndView.addObject("casTicketSuffix", this.casTicketSuffix); int unexpiredTgts = 0; int unexpiredSts = 0; int expiredTgts = 0; int expiredSts = 0; try { final Collection<Ticket> tickets = this.centralAuthenticationService.getTickets(TruePredicate.INSTANCE); for (final Ticket ticket : tickets) { if (ticket instanceof ServiceTicket) { if (ticket.isExpired()) { expiredSts++; } else { unexpiredSts++; } } else { if (ticket.isExpired()) { expiredTgts++; } else { unexpiredTgts++; } } } } catch (final UnsupportedOperationException e) { logger.trace("The ticket registry doesn't support this information."); } modelAndView.addObject("unexpiredTgts", unexpiredTgts); modelAndView.addObject("unexpiredSts", unexpiredSts); modelAndView.addObject("expiredTgts", expiredTgts); modelAndView.addObject("expiredSts", expiredSts); modelAndView.addObject("pageTitle", modelAndView.getViewName()); return modelAndView; }