DomainApiUtils { public static boolean isObjectAvailableNow(final boolean enabled, final LocalDateTime availableFrom, final LocalDateTime availableTo, final LocalDateTime now) { if (!enabled) { return false; } if (availableFrom != null && now.isBefore(availableFrom)) { return false; } if (availableTo != null && now.isAfter(availableTo)) { return false; } return true; } private  DomainApiUtils(); static String getAttributeValue(final String attrCode, final Map<String, AttrValue> values); static String getAttributeValue(final String attrCode, final Collection<? extends AttrValue> attributes); static boolean isObjectAvailableNow(final boolean enabled,
                                               final LocalDateTime availableFrom,
                                               final LocalDateTime availableTo,
                                               final LocalDateTime now);  }
@Test public void testIsObjectAvailableNow() throws Exception { final LocalDateTime now = LocalDateTime.now(); assertFalse(DomainApiUtils.isObjectAvailableNow(false, null, null, now)); assertTrue(DomainApiUtils.isObjectAvailableNow(true, null, null, now)); assertFalse(DomainApiUtils.isObjectAvailableNow(true, now.plusSeconds(1L), null, now)); assertTrue(DomainApiUtils.isObjectAvailableNow(true, now.plusSeconds(-1L), null, now)); assertFalse(DomainApiUtils.isObjectAvailableNow(true, null, now.plusSeconds(-1L), now)); assertTrue(DomainApiUtils.isObjectAvailableNow(true, null, now.plusSeconds(1L), now)); assertTrue(DomainApiUtils.isObjectAvailableNow(true, now.plusSeconds(-1L), now.plusSeconds(1L), now)); }