@Test public void searchTest() { List<Ven> vens = new ArrayList<>(); List<DemandResponseEvent> events = new ArrayList<>(); VenMarketContext marketContext = null; Ven ven1; Ven ven2; Ven ven3; DemandResponseEvent event1 = null; DemandResponseEvent event2 = null; DemandResponseEvent event3 = null; String marketContextName = "http: marketContext = venMarketContextService.prepare(new VenMarketContextDto(marketContextName)); venMarketContextService.save(marketContext); String groupName = "group1"; VenGroup group = venGroupService.prepare(new VenGroupDto(groupName)); venGroupService.save(group); ven1 = venService.prepare("ven1"); ven1.setVenMarketContexts(Sets.newHashSet(marketContext)); ven1.setVenGroup(Sets.newHashSet(group)); ven1 = venService.save(ven1); vens.add(ven1); ven2 = venService.prepare("ven2"); ven2.setVenMarketContexts(Sets.newHashSet(marketContext)); ven2 = venService.save(ven2); vens.add(ven2); ven3 = venService.prepare("ven3"); ven3.setVenMarketContexts(Sets.newHashSet(marketContext)); ven3.setVenGroup(Sets.newHashSet(group)); ven3 = venService.save(ven3); vens.add(ven3); String duration = "PT1H"; String notificationDuration = "P1D"; DemandResponseEventStateEnum state = DemandResponseEventStateEnum.ACTIVE; DemandResponseEventSignalDto signal = new DemandResponseEventSignalDto(); signal.setCurrentValue(DemandResponseEventSimpleValueEnum.SIMPLE_SIGNAL_PAYLOAD_HIGH.getValue()); signal.setSignalName("SIMPLE"); signal.setSignalType("level"); DemandResponseEventCreateDto dto = new DemandResponseEventCreateDto(); dto.getDescriptor().setState(state); dto.getDescriptor().setOadrProfile(DemandResponseEventOadrProfileEnum.OADR20B); dto.getActivePeriod().setStart(start); dto.getDescriptor().setMarketContext(marketContext.getName()); dto.getActivePeriod().setDuration(duration); dto.getActivePeriod().setNotificationDuration(notificationDuration); dto.getTargets().add(new DemandResponseEventTargetDto("ven", "ven1")); dto.getTargets().add(new DemandResponseEventTargetDto("ven", "ven2")); dto.getSignals().add(signal); dto.setPublished(true); event1 = demandResponseEventService.create(dto); events.add(event1); dto = new DemandResponseEventCreateDto(); dto.getDescriptor().setState(DemandResponseEventStateEnum.CANCELLED); dto.getDescriptor().setOadrProfile(DemandResponseEventOadrProfileEnum.OADR20B); dto.getActivePeriod().setStart(start); dto.getDescriptor().setMarketContext(marketContext.getName()); dto.getActivePeriod().setDuration(duration); dto.getActivePeriod().setNotificationDuration(notificationDuration); dto.getActivePeriod().setRampUpDuration("PT1H"); dto.getActivePeriod().setRecoveryDuration("PT1H"); dto.getDescriptor().setVtnComment("comment"); dto.getTargets().add(new DemandResponseEventTargetDto("ven", "ven2")); dto.getSignals().add(signal); dto.setPublished(true); event2 = demandResponseEventService.create(dto); events.add(event2); dto = new DemandResponseEventCreateDto(); dto.getDescriptor().setOadrProfile(DemandResponseEventOadrProfileEnum.OADR20B); dto.getDescriptor().setState(state); dto.getActivePeriod().setStart(start); dto.getDescriptor().setMarketContext(marketContext.getName()); dto.getActivePeriod().setDuration(duration); dto.getActivePeriod().setNotificationDuration(notificationDuration); dto.getTargets().add(new DemandResponseEventTargetDto("ven", "ven3")); dto.getSignals().add(signal); dto.setPublished(true); event3 = demandResponseEventService.create(dto); events.add(event3); String event1Id = String.valueOf(event1.getId()); String event2Id = String.valueOf(event2.getId()); String event3Id = String.valueOf(event3.getId()); List<VenFilter> filters = new ArrayList<>(); Page<Ven> search = venService.search(filters); assertEquals(3, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.EVENT, event1Id)); search = venService.search(filters); assertEquals(2, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.EVENT, event2Id)); search = venService.search(filters); assertEquals(1, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.EVENT, event3Id)); search = venService.search(filters); assertEquals(1, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.EVENT, event1Id)); filters.add(getFilter(VenFilterType.EVENT, event2Id)); search = venService.search(filters); assertEquals(2, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.EVENT, event1Id)); filters.add(getFilter(VenFilterType.EVENT, event2Id)); filters.add(getFilter(VenFilterType.EVENT, event3Id)); search = venService.search(filters); assertEquals(3, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.IS_REGISTERED, Boolean.TRUE.toString())); search = venService.search(filters); assertEquals(0, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.IS_REGISTERED, Boolean.FALSE.toString())); search = venService.search(filters); assertEquals(3, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.GROUP, groupName)); search = venService.search(filters); assertEquals(2, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.GROUP, groupName)); filters.add(getFilter(VenFilterType.EVENT, event1Id)); search = venService.search(filters); assertEquals(1, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.MARKET_CONTEXT, marketContextName)); filters.add(getFilter(VenFilterType.EVENT, event1Id)); search = venService.search(filters); assertEquals(2, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.MARKET_CONTEXT, marketContextName)); filters.add(getFilter(VenFilterType.EVENT, event1Id)); filters.add(getFilter(VenFilterType.VEN, "ven1")); search = venService.search(filters); assertEquals(1, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.MARKET_CONTEXT, marketContextName)); filters.add(getFilter(VenFilterType.EVENT, event1Id)); filters.add(getFilter(VenFilterType.VEN, "ven")); search = venService.search(filters); assertEquals(2, search.getTotalElements()); filters = new ArrayList<>(); filters.add(getFilter(VenFilterType.MARKET_CONTEXT, marketContextName)); filters.add(getFilter(VenFilterType.EVENT, event1Id)); filters.add(getFilter(VenFilterType.VEN, "mouaiccool")); search = venService.search(filters); assertEquals(0, search.getTotalElements()); demandResponseEventService.delete(events); venService.delete(vens); venMarketContextService.delete(marketContext); venGroupService.delete(group); }
public Page<Ven> search(List<VenFilter> filters) { return search(filters, null, null); }
VenService extends AbstractUserService<Ven> { public Page<Ven> search(List<VenFilter> filters) { return search(filters, null, null); } }
VenService extends AbstractUserService<Ven> { public Page<Ven> search(List<VenFilter> filters) { return search(filters, null, null); }  }
VenService extends AbstractUserService<Ven> { public Page<Ven> search(List<VenFilter> filters) { return search(filters, null, null); }  Ven prepare(String username, String password); Ven prepare(String username); Ven prepare(VenCreateDto dto); Optional<File> generateCertificateIfRequired(VenCreateDto dto, Ven ven); @Override @Transactional void delete(Ven instance); @Override void delete(Iterable<Ven> instances); @Override Ven save(Ven instance); @Override void save(Iterable<Ven> instances); Ven findOneByUsername(String username); Ven findOneByRegistrationId(String registrationId); List<Ven> findByUsernameInAndVenMarketContextsContains(List<String> username,
			VenMarketContext venMarketContext); List<Ven> findByGroupName(List<String> groupName); List<Ven> findByMarketContextName(List<String> groupName); Ven findOne(Long id); Iterable<Ven> findAll(); long count(); void cleanRegistration(Ven ven); Page<Ven> search(List<VenFilter> filters); Page<Ven> search(List<VenFilter> filters, Integer page, Integer size); }
VenService extends AbstractUserService<Ven> { public Page<Ven> search(List<VenFilter> filters) { return search(filters, null, null); }  Ven prepare(String username, String password); Ven prepare(String username); Ven prepare(VenCreateDto dto); Optional<File> generateCertificateIfRequired(VenCreateDto dto, Ven ven); @Override @Transactional void delete(Ven instance); @Override void delete(Iterable<Ven> instances); @Override Ven save(Ven instance); @Override void save(Iterable<Ven> instances); Ven findOneByUsername(String username); Ven findOneByRegistrationId(String registrationId); List<Ven> findByUsernameInAndVenMarketContextsContains(List<String> username,
			VenMarketContext venMarketContext); List<Ven> findByGroupName(List<String> groupName); List<Ven> findByMarketContextName(List<String> groupName); Ven findOne(Long id); Iterable<Ven> findAll(); long count(); void cleanRegistration(Ven ven); Page<Ven> search(List<VenFilter> filters); Page<Ven> search(List<VenFilter> filters, Integer page, Integer size);  }