public void testInstallAtLocation() throws BundleException, MalformedURLException, IOException { // create disconnected test regions Region r1 = digraph.createRegion(getName() + ".1"); Region r2 = digraph.createRegion(getName() + ".2"); String location = bundleInstaller.getBundleLocation(PP1); Bundle b1 = null; Bundle b2 = null; String l1 = null; String l2 = null; try { URL url = new URL(location); b1 = r1.installBundle(location + ".1", url.openStream()); l1 = b1.getLocation(); b2 = r2.installBundleAtLocation(location + ".2", url.openStream()); l2 = b2.getLocation(); } finally { if (b1 != null) { try { b1.uninstall(); } catch (BundleException e) { // ignore } } if (b2 != null) { try { b2.uninstall(); } catch (BundleException e) { // ignore } } } assertEquals("Wrong location found.", location + ".1#" + r1.getName(), l1); assertEquals("Wrong location found.", location + ".2", l2); }
public String getVacationListByRegionJSON( Date dateFrom, Date dateTo, List<Vacation> vacationList) { List<Region> regionList = regionService.getRegions(); List<Employee> employeeList = new ArrayList<Employee>(); for (Vacation vacation : vacationList) { Employee employee = vacation.getEmployee(); if (!(employeeList.contains(employee))) { employeeList.add(employee); } } final JsonArrayNodeBuilder result = anArrayBuilder(); // для каждого проекта смотрим сотрудников у которых есть отпуск for (Region region : regionList) { JsonArrayNodeBuilder employeeNode = anArrayBuilder(); boolean hasEmployees = false; for (Employee employee : employeeList) { if (employee.getRegion().getId().equals(region.getId())) { JsonArrayNodeBuilder vacationNode = createVacationsNode(employee, vacationList); hasEmployees = true; employeeNode.withElement( anObjectBuilder() .withField("employee", aStringBuilder(employee.getName())) .withField("vacations", vacationNode)); } } if (hasEmployees) { result.withElement( anObjectBuilder() .withField("region_id", aStringBuilder(region.getId().toString())) .withField("region_name", aStringBuilder(region.getName())) .withField("employeeList", employeeNode) .withField("holidays", getHolidayInRegion(dateFrom, dateTo, region))); } } return JsonUtil.format(result); }