public void testFindById() throws Exception { loadDataSetXml("admin/commserver/seedLocationsAndServices.xml"); Location[] locations = m_out.getLocations(); Location firstLocation = locations[0]; int locationId = firstLocation.getId(); Location locationById = m_out.getLocation(locationId); assertNotNull(locationById); assertEquals(firstLocation.getName(), locationById.getName()); Collection<LocationSpecificService> services = locationById.getServices(); assertNotNull(services); assertEquals(3, services.size()); }
private static final List<List<Location>> gridWith( List<Location> topRow, Location topLeft, Location bottomLeft) { int rowCount = topLeft.equals(bottomLeft) ? 1 : topLeft.distanceFrom(bottomLeft) + 1; return Stream.iterate(topRow, row -> row.stream().map(Location::south).collect(toList())) .limit(rowCount) .collect(toList()); }
public void testStore() throws Exception { loadDataSetXml("admin/commserver/clearLocations.xml"); Location location = new Location(); location.setName("test location"); location.setAddress("192.168.1.2"); location.setFqdn("localhost"); m_out.storeLocation(location); Location[] dbLocations = m_out.getLocations(); assertEquals(1, dbLocations.length); assertEquals("test location", dbLocations[0].getName()); assertEquals("192.168.1.2", dbLocations[0].getAddress()); assertEquals("localhost", dbLocations[0].getFqdn()); }
private static Class<?> type(Location location) { try { return Class.forName(location.getClassName()); } catch (Exception e) { throw new RuntimeException(e); } }
private List<Location> neighboursOf(Location location) { return asList( location.northWest(), location.north(), location.northEast(), location.west(), /* location */ location.east(), location.southWest(), location.south(), location.southEast()); }
public void testAcdBridgePublishSaveDelete() throws Exception { loadDataSetXml("admin/commserver/clearLocations.xml"); Location[] emptyLocations = m_out.getLocations(); assertEquals(0, emptyLocations.length); assertEquals(0, m_acdContext.getServers().size()); Location location = new Location(); location.setName("test location"); location.setAddress("192.168.1.2"); location.setFqdn("location1"); location.setInstalledBundles(asList("callCenterBundle")); m_out.storeLocation(location); assertEquals(1, m_acdContext.getServers().size()); assertEquals(0, m_conferenceBridgeContext.getBridges().size()); SipxService freeswitchService = new SipxFreeswitchService(); freeswitchService.setBeanId(SipxFreeswitchService.BEAN_ID); LocationSpecificService service = new LocationSpecificService(); service.setSipxService(freeswitchService); service.setLocation(location); location.addService(freeswitchService); location.setInstalledBundles(asList("callCenterBundle", "conferenceBundle")); m_out.storeLocation(location); assertEquals(1, m_acdContext.getServers().size()); assertEquals(1, m_conferenceBridgeContext.getBridges().size()); location.setInstalledBundles(asList("callCenterBundle")); m_out.storeLocation(location); assertEquals(1, m_acdContext.getServers().size()); assertEquals(0, m_conferenceBridgeContext.getBridges().size()); location.setInstalledBundles(Collections.<String>emptyList()); m_out.storeLocation(location); assertEquals(0, m_acdContext.getServers().size()); assertEquals(0, m_conferenceBridgeContext.getBridges().size()); }
private static final List<Location> topRowWith(Location topLeft, Location topRight) { int columnCount = topLeft.equals(topRight) ? 1 : topLeft.distanceFrom(topRight) + 1; return Stream.iterate(topLeft, Location::east).limit(columnCount).collect(toList()); }
private static final Location getTopLeft(Location northMost, Location westMost) { return Stream.iterate(northMost, Location::west) .filter(location -> !westMost.isWestOf(location)) .findFirst() .get(); }
private static final Location getTopRight(Location northMost, Location eastMost) { return Stream.iterate(northMost, Location::east) .filter(location -> !eastMost.isEastOf(location)) .findFirst() .get(); }
private static final Location getBottomLeft(Location northMost, Location southMost) { return Stream.iterate(northMost, Location::south) .filter(location -> !southMost.isSouthOf(location)) .findFirst() .get(); }
public void testGetPrimaryLocation() throws Exception { loadDataSetXml("admin/commserver/seedLocations.xml"); Location location = m_out.getPrimaryLocation(); assertNotNull(location); assertEquals(101, (int) location.getId()); }