target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void whenAddingTimeAndDistanceToSymmetricMatrix_itShouldReturnCorrectValues() { FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(3, true); matrixBuilder.addTransportDistance(1, 2, 20.); matrixBuilder.addTransportTime(1, 2, 2.); FastVe...
@Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + from + " to " + to + " < 0 "); if (vehicle == null) return getDistance(from.getIndex(), to.getI...
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr...
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr...
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr...
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr...
@Test public void whenAddingTimeAndDistanceToAsymmetricMatrix_itShouldReturnCorrectValues() { FastVehicleRoutingTransportCostsMatrix.Builder matrixBuilder = FastVehicleRoutingTransportCostsMatrix.Builder.newInstance(3, false); matrixBuilder.addTransportTime(1, 2, 2.); matrixBuilder.addTransportTime(2, 1, 8.); FastVehic...
@Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + from + " to " + to + " < 0 "); if (vehicle == null) return getDistance(from.getIndex(), to.getI...
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr...
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr...
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr...
FastVehicleRoutingTransportCostsMatrix extends AbstractForwardVehicleRoutingTransportCosts { @Override public double getTransportCost(Location from, Location to, double departureTime, Driver driver, Vehicle vehicle) { if (from.getIndex() < 0 || to.getIndex() < 0) throw new IllegalArgumentException("index of from " + fr...
@Test public void shouldReturnSingleJob() { Job job = mock(Job.class); Collection<Job> jobs = Arrays.asList(job); Assert.assertEquals(job, RandomUtils.nextItem(jobs, RandomNumberGeneration.getRandom())); }
public static <T> T nextItem(Collection<T> items, Random random) { int randomIndex = random.nextInt(items.size()); int count = 0; for (T item : items) { if (count == randomIndex) return item; count++; } return null; }
RandomUtils { public static <T> T nextItem(Collection<T> items, Random random) { int randomIndex = random.nextInt(items.size()); int count = 0; for (T item : items) { if (count == randomIndex) return item; count++; } return null; } }
RandomUtils { public static <T> T nextItem(Collection<T> items, Random random) { int randomIndex = random.nextInt(items.size()); int count = 0; for (T item : items) { if (count == randomIndex) return item; count++; } return null; } }
RandomUtils { public static <T> T nextItem(Collection<T> items, Random random) { int randomIndex = random.nextInt(items.size()); int count = 0; for (T item : items) { if (count == randomIndex) return item; count++; } return null; } static VehicleRoute nextRoute(Collection<VehicleRoute> routes, Random random); static J...
RandomUtils { public static <T> T nextItem(Collection<T> items, Random random) { int randomIndex = random.nextInt(items.size()); int count = 0; for (T item : items) { if (count == randomIndex) return item; count++; } return null; } static VehicleRoute nextRoute(Collection<VehicleRoute> routes, Random random); static J...
@Test public void whenReadingCustomersCordeauInstance_customerThreeShouldHaveCorrectDemand() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new CordeauReader(vrpBuilder).read(getPath("p01")); VehicleRoutingProblem vrp = vrpBuilder.build(); Service service = (Service) vrp.getJo...
public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder>>(); int depotC...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
@Test public void shouldReturnSingleJob_() { Job job = mock(Job.class); Collection<Job> jobs = Arrays.asList(job); Assert.assertEquals(job, RandomUtils.nextJob(jobs, RandomNumberGeneration.getRandom())); }
public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); }
RandomUtils { public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); } }
RandomUtils { public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); } }
RandomUtils { public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); } static VehicleRoute nextRoute(Collection<VehicleRoute> routes, Random random); static Job nextJob(Collection<Job> jobs, Random random); static Job nextJob(List<Job> jobs, Random random); static T nextItem(Co...
RandomUtils { public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); } static VehicleRoute nextRoute(Collection<VehicleRoute> routes, Random random); static Job nextJob(Collection<Job> jobs, Random random); static Job nextJob(List<Job> jobs, Random random); static T nextItem(Co...
@Test public void shouldReturnJob3() { Job job3 = mock(Job.class); List<Job> jobs = Arrays.asList(mock(Job.class), mock(Job.class), job3); Random random = mock(Random.class); when(random.nextInt(jobs.size())).thenReturn(2); Assert.assertEquals(job3, RandomUtils.nextJob(jobs, random)); }
public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); }
RandomUtils { public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); } }
RandomUtils { public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); } }
RandomUtils { public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); } static VehicleRoute nextRoute(Collection<VehicleRoute> routes, Random random); static Job nextJob(Collection<Job> jobs, Random random); static Job nextJob(List<Job> jobs, Random random); static T nextItem(Co...
RandomUtils { public static Job nextJob(Collection<Job> jobs, Random random) { return nextItem(jobs, random); } static VehicleRoute nextRoute(Collection<VehicleRoute> routes, Random random); static Job nextJob(Collection<Job> jobs, Random random); static Job nextJob(List<Job> jobs, Random random); static T nextItem(Co...
@Test public void test() { double lon1 = 8.3858333; double lat1 = 49.0047222; double lon2 = 12.1333333; double lat2 = 54.0833333; double greatCircle = GreatCircleDistanceCalculator.calculateDistance( Coordinate.newInstance(lon1, lat1), Coordinate.newInstance(lon2, lat2), DistanceUnit.Kilometer ); Assert.assertEquals(60...
public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon = Math.toRadians(lon2 - lon1); la...
GreatCircleDistanceCalculator { public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon =...
GreatCircleDistanceCalculator { public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon =...
GreatCircleDistanceCalculator { public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon =...
GreatCircleDistanceCalculator { public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon =...
@Test public void testMeter() { double lon1 = 8.3858333; double lat1 = 49.0047222; double lon2 = 12.1333333; double lat2 = 54.0833333; double greatCircle = GreatCircleDistanceCalculator.calculateDistance( Coordinate.newInstance(lon1, lat1), Coordinate.newInstance(lon2, lat2), DistanceUnit.Meter ); Assert.assertEquals(6...
public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon = Math.toRadians(lon2 - lon1); la...
GreatCircleDistanceCalculator { public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon =...
GreatCircleDistanceCalculator { public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon =...
GreatCircleDistanceCalculator { public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon =...
GreatCircleDistanceCalculator { public static double calculateDistance(Coordinate coord1, Coordinate coord2, DistanceUnit distanceUnit) { double lon1 = coord1.getX(); double lon2 = coord2.getX(); double lat1 = coord1.getY(); double lat2 = coord2.getY(); double delta_Lat = Math.toRadians(lat2 - lat1); double delta_Lon =...
@Test public void testGetVehicles() { Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles(); assertEquals(2, vehicles.size()); }
@Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; } }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; } VehicleFleetMan...
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; } VehicleFleetMan...
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; } VehicleFleetMan...
@Test public void testLock() { fleetManager.lock(v1); Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles(); assertEquals(1, vehicles.size()); }
@Override public void lock(Vehicle vehicle) { if (vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } if(locked[vehicle.getIndex()]){ throw new IllegalStateException("cannot lock vehicle twice " + vehicle.getId()); } else{ locked[vehicle.getIndex()] = true; removeVehicle(vehicle); } }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void lock(Vehicle vehicle) { if (vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } if(locked[vehicle.getIndex()]){ throw new IllegalStateException("cannot lock vehicle twice " + vehicle.getId()); } else{ locked[vehicle.g...
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void lock(Vehicle vehicle) { if (vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } if(locked[vehicle.getIndex()]){ throw new IllegalStateException("cannot lock vehicle twice " + vehicle.getId()); } else{ locked[vehicle.g...
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void lock(Vehicle vehicle) { if (vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } if(locked[vehicle.getIndex()]){ throw new IllegalStateException("cannot lock vehicle twice " + vehicle.getId()); } else{ locked[vehicle.g...
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void lock(Vehicle vehicle) { if (vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } if(locked[vehicle.getIndex()]){ throw new IllegalStateException("cannot lock vehicle twice " + vehicle.getId()); } else{ locked[vehicle.g...
@Test public void testIsLocked() { fleetManager.lock(v1); assertTrue(fleetManager.isLocked(v1)); }
@Override public boolean isLocked(Vehicle vehicle) { return locked[vehicle.getIndex()]; }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public boolean isLocked(Vehicle vehicle) { return locked[vehicle.getIndex()]; } }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public boolean isLocked(Vehicle vehicle) { return locked[vehicle.getIndex()]; } VehicleFleetManagerImpl(Collection<Vehicle> vehicles); }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public boolean isLocked(Vehicle vehicle) { return locked[vehicle.getIndex()]; } VehicleFleetManagerImpl(Collection<Vehicle> vehicles); VehicleFleetManagerImpl newInstance(Collection<Vehicle> vehicles); @Override String toString(); @Override Collection<V...
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public boolean isLocked(Vehicle vehicle) { return locked[vehicle.getIndex()]; } VehicleFleetManagerImpl(Collection<Vehicle> vehicles); VehicleFleetManagerImpl newInstance(Collection<Vehicle> vehicles); @Override String toString(); @Override Collection<V...
@Test public void testGetVehiclesWithout() { Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles(v1); assertEquals(v2, vehicles.iterator().next()); assertEquals(1, vehicles.size()); }
@Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; } }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; } VehicleFleetMan...
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; } VehicleFleetMan...
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public Collection<Vehicle> getAvailableVehicles() { List<Vehicle> vehicles = new ArrayList<>(); for (TypeContainer vehicleType : vehicleTypes) { if (!vehicleType.isEmpty()) { vehicles.add(vehicleType.getVehicle()); } } return vehicles; } VehicleFleetMan...
@Test public void testUnlock() { fleetManager.lock(v1); Collection<Vehicle> vehicles = fleetManager.getAvailableVehicles(); assertEquals(1, vehicles.size()); fleetManager.unlock(v1); Collection<Vehicle> vehicles_ = fleetManager.getAvailableVehicles(); assertEquals(2, vehicles_.size()); }
@Override public void unlock(Vehicle vehicle) { if (vehicle == null || vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } locked[vehicle.getIndex()] = false; addVehicle(vehicle); }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void unlock(Vehicle vehicle) { if (vehicle == null || vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } locked[vehicle.getIndex()] = false; addVehicle(vehicle); } }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void unlock(Vehicle vehicle) { if (vehicle == null || vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } locked[vehicle.getIndex()] = false; addVehicle(vehicle); } VehicleFleetManagerImpl(Collection<Vehicle> vehicles); }
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void unlock(Vehicle vehicle) { if (vehicle == null || vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } locked[vehicle.getIndex()] = false; addVehicle(vehicle); } VehicleFleetManagerImpl(Collection<Vehicle> vehicles); Ve...
VehicleFleetManagerImpl implements VehicleFleetManager { @Override public void unlock(Vehicle vehicle) { if (vehicle == null || vehicles.isEmpty() || vehicle instanceof VehicleImpl.NoVehicle) { return; } locked[vehicle.getIndex()] = false; addVehicle(vehicle); } VehicleFleetManagerImpl(Collection<Vehicle> vehicles); Ve...
@Test public void whenAddingDriverBreak_itShouldBeAddedCorrectly() { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build(); Break aBreak = Break.Builder.newInstance("break").setTimeWindow(TimeWindow.newInstance(100, 200)).setServiceTime(30).build(); Vehicle v = VehicleImpl.Builder.newInstance("v")...
@Override public Break getBreak() { return aBreak; }
VehicleImpl extends AbstractVehicle { @Override public Break getBreak() { return aBreak; } }
VehicleImpl extends AbstractVehicle { @Override public Break getBreak() { return aBreak; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public Break getBreak() { return aBreak; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestArrival(); @Overri...
VehicleImpl extends AbstractVehicle { @Override public Break getBreak() { return aBreak; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestArrival(); @Overri...
@Test public void whenReadingCustomersCordeauInstance_customerFortySevenShouldHaveCorrectDemand() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new CordeauReader(vrpBuilder).read(getPath("p01")); VehicleRoutingProblem vrp = vrpBuilder.build(); Service service = (Service) vrp....
public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder>>(); int depotC...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
@Test public void whenAddingSkills_theyShouldBeAddedCorrectly() { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build(); Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setType(type1).setEndLocation(Location.newInstance("start")) .addSkill("drill")....
@Override public Skills getSkills() { return skills; }
VehicleImpl extends AbstractVehicle { @Override public Skills getSkills() { return skills; } }
VehicleImpl extends AbstractVehicle { @Override public Skills getSkills() { return skills; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public Skills getSkills() { return skills; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestArrival(); @Over...
VehicleImpl extends AbstractVehicle { @Override public Skills getSkills() { return skills; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestArrival(); @Over...
@Test public void whenAddingSkillsCaseSens_theyShouldBeAddedCorrectly() { VehicleTypeImpl type1 = VehicleTypeImpl.Builder.newInstance("type").build(); Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance("start")).setType(type1).setEndLocation(Location.newInstance("start")) .addSkill("...
@Override public Skills getSkills() { return skills; }
VehicleImpl extends AbstractVehicle { @Override public Skills getSkills() { return skills; } }
VehicleImpl extends AbstractVehicle { @Override public Skills getSkills() { return skills; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public Skills getSkills() { return skills; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestArrival(); @Over...
VehicleImpl extends AbstractVehicle { @Override public Skills getSkills() { return skills; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestArrival(); @Over...
@Test public void whenVehicleIsBuiltToReturnToDepot_itShouldReturnToDepot() { Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(true).setStartLocation(Location.newInstance("loc")).build(); assertTrue(v.isReturnToDepot()); }
@Override public boolean isReturnToDepot() { return returnToDepot; }
VehicleImpl extends AbstractVehicle { @Override public boolean isReturnToDepot() { return returnToDepot; } }
VehicleImpl extends AbstractVehicle { @Override public boolean isReturnToDepot() { return returnToDepot; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public boolean isReturnToDepot() { return returnToDepot; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestAr...
VehicleImpl extends AbstractVehicle { @Override public boolean isReturnToDepot() { return returnToDepot; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestAr...
@Test public void whenVehicleIsBuiltToNotReturnToDepot_itShouldNotReturnToDepot() { Vehicle v = VehicleImpl.Builder.newInstance("v").setReturnToDepot(false).setStartLocation(Location.newInstance("loc")).build(); assertFalse(v.isReturnToDepot()); }
@Override public boolean isReturnToDepot() { return returnToDepot; }
VehicleImpl extends AbstractVehicle { @Override public boolean isReturnToDepot() { return returnToDepot; } }
VehicleImpl extends AbstractVehicle { @Override public boolean isReturnToDepot() { return returnToDepot; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public boolean isReturnToDepot() { return returnToDepot; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestAr...
VehicleImpl extends AbstractVehicle { @Override public boolean isReturnToDepot() { return returnToDepot; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestAr...
@Test public void whenVehicleIsBuiltWithCoord_itShouldHvTheCorrectCoord() { Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1, 2)).build(); assertEquals(1.0, v.getStartLocation().getCoordinate().getX(), 0.01); assertEquals(2.0, v.getStartLocation().getCoordinate().getY(), 0.01); }
@Override public Location getStartLocation() { return startLocation; }
VehicleImpl extends AbstractVehicle { @Override public Location getStartLocation() { return startLocation; } }
VehicleImpl extends AbstractVehicle { @Override public Location getStartLocation() { return startLocation; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public Location getStartLocation() { return startLocation; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatest...
VehicleImpl extends AbstractVehicle { @Override public Location getStartLocation() { return startLocation; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatest...
@Test public void whenVehicleIsBuiltAndEarliestStartIsNotSet_itShouldSetTheDefaultOfZero() { Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1, 2)).build(); assertEquals(0.0, v.getEarliestDeparture(), 0.01); }
@Override public double getEarliestDeparture() { return earliestDeparture; }
VehicleImpl extends AbstractVehicle { @Override public double getEarliestDeparture() { return earliestDeparture; } }
VehicleImpl extends AbstractVehicle { @Override public double getEarliestDeparture() { return earliestDeparture; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public double getEarliestDeparture() { return earliestDeparture; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double get...
VehicleImpl extends AbstractVehicle { @Override public double getEarliestDeparture() { return earliestDeparture; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double get...
@Test public void whenVehicleIsBuiltAndEarliestStartSet_itShouldBeSetCorrectly() { Vehicle v = VehicleImpl.Builder.newInstance("v").setEarliestStart(10.0).setStartLocation(Location.newInstance(1, 2)).build(); assertEquals(10.0, v.getEarliestDeparture(), 0.01); }
@Override public double getEarliestDeparture() { return earliestDeparture; }
VehicleImpl extends AbstractVehicle { @Override public double getEarliestDeparture() { return earliestDeparture; } }
VehicleImpl extends AbstractVehicle { @Override public double getEarliestDeparture() { return earliestDeparture; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public double getEarliestDeparture() { return earliestDeparture; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double get...
VehicleImpl extends AbstractVehicle { @Override public double getEarliestDeparture() { return earliestDeparture; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double get...
@Test public void whenVehicleIsBuiltAndLatestArrivalIsNotSet_itShouldSetDefaultOfDoubleMaxValue() { Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1, 2)).build(); assertEquals(Double.MAX_VALUE, v.getLatestArrival(), 0.01); }
@Override public double getLatestArrival() { return latestArrival; }
VehicleImpl extends AbstractVehicle { @Override public double getLatestArrival() { return latestArrival; } }
VehicleImpl extends AbstractVehicle { @Override public double getLatestArrival() { return latestArrival; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public double getLatestArrival() { return latestArrival; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestAr...
VehicleImpl extends AbstractVehicle { @Override public double getLatestArrival() { return latestArrival; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestAr...
@Test public void whenVehicleIsBuiltAndLatestArrivalIsSet_itShouldBeSetCorrectly() { Vehicle v = VehicleImpl.Builder.newInstance("v").setLatestArrival(30.0).setStartLocation(Location.newInstance(1, 2)).build(); assertEquals(30.0, v.getLatestArrival(), 0.01); }
@Override public double getLatestArrival() { return latestArrival; }
VehicleImpl extends AbstractVehicle { @Override public double getLatestArrival() { return latestArrival; } }
VehicleImpl extends AbstractVehicle { @Override public double getLatestArrival() { return latestArrival; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public double getLatestArrival() { return latestArrival; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestAr...
VehicleImpl extends AbstractVehicle { @Override public double getLatestArrival() { return latestArrival; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatestAr...
@Test public void whenStartLocationCoordIsSet_itIsDoneCorrectly() { Vehicle v = VehicleImpl.Builder.newInstance("v").setStartLocation(Location.newInstance(1, 2)).build(); assertEquals(1.0, v.getStartLocation().getCoordinate().getX(), 0.01); assertEquals(2.0, v.getStartLocation().getCoordinate().getY(), 0.01); }
@Override public Location getStartLocation() { return startLocation; }
VehicleImpl extends AbstractVehicle { @Override public Location getStartLocation() { return startLocation; } }
VehicleImpl extends AbstractVehicle { @Override public Location getStartLocation() { return startLocation; } private VehicleImpl(Builder builder); }
VehicleImpl extends AbstractVehicle { @Override public Location getStartLocation() { return startLocation; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatest...
VehicleImpl extends AbstractVehicle { @Override public Location getStartLocation() { return startLocation; } private VehicleImpl(Builder builder); static Vehicle copyOf(Vehicle vehicle); static NoVehicle createNoVehicle(); @Override String toString(); @Override double getEarliestDeparture(); @Override double getLatest...
@Test public void testLocationsAndCapOfVehicles() { VehicleRoutingProblem.Builder vrpBuilder = VehicleRoutingProblem.Builder.newInstance(); new CordeauReader(vrpBuilder).read(getPath("p01")); VehicleRoutingProblem vrp = vrpBuilder.build(); boolean capacityOk = true; boolean loc1ok = false; boolean loc2ok = false; boole...
public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder>>(); int depotC...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
CordeauReader { public void read(String fileName) { vrpBuilder.setFleetSize(FleetSize.FINITE); BufferedReader reader = getReader(fileName); int vrpType; int nOfDepots = 0; int nOfCustomers = 0; int nOfVehiclesAtEachDepot = 0; int counter = 0; String line; List<List<Builder>> vehiclesAtDepot = new ArrayList<List<Builder...
@Test public void findByKey() throws Exception { UserDO user = userService.findById(1L); System.out.println(user); }
@RequestMapping(value = "/query/{key}", method = RequestMethod.GET) @PostAuthorize("hasRole('ADMIN') or (returnObject.username == principal.username)") @ApiOperation(value = "按某属性查询用户", notes = "属性可以是id或username或email或手机号", response = UserDO.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = { @Api...
UserController { @RequestMapping(value = "/query/{key}", method = RequestMethod.GET) @PostAuthorize("hasRole('ADMIN') or (returnObject.username == principal.username)") @ApiOperation(value = "按某属性查询用户", notes = "属性可以是id或username或email或手机号", response = UserDO.class, authorizations = {@Authorization("登录权限")}) @ApiRespons...
UserController { @RequestMapping(value = "/query/{key}", method = RequestMethod.GET) @PostAuthorize("hasRole('ADMIN') or (returnObject.username == principal.username)") @ApiOperation(value = "按某属性查询用户", notes = "属性可以是id或username或email或手机号", response = UserDO.class, authorizations = {@Authorization("登录权限")}) @ApiRespons...
UserController { @RequestMapping(value = "/query/{key}", method = RequestMethod.GET) @PostAuthorize("hasRole('ADMIN') or (returnObject.username == principal.username)") @ApiOperation(value = "按某属性查询用户", notes = "属性可以是id或username或email或手机号", response = UserDO.class, authorizations = {@Authorization("登录权限")}) @ApiRespons...
UserController { @RequestMapping(value = "/query/{key}", method = RequestMethod.GET) @PostAuthorize("hasRole('ADMIN') or (returnObject.username == principal.username)") @ApiOperation(value = "按某属性查询用户", notes = "属性可以是id或username或email或手机号", response = UserDO.class, authorizations = {@Authorization("登录权限")}) @ApiRespons...
@Test public void createUser() throws Exception { BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); String password = passwordEncoder.encode("user1"); System.out.println(password); }
@ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "创建用户,为用户发送验证邮件,等待用户激活,若24小时内未激活需要重新注册", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 409, message = "用户名已存在"), @ApiResponse(code = 400, message = "用户属性校验失败") }) public void createUser(@RequestBo...
UserController { @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "创建用户,为用户发送验证邮件,等待用户激活,若24小时内未激活需要重新注册", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 409, message = "用户名已存在"), @ApiResponse(code = 400, message = "用户属性校验失败") }) public void crea...
UserController { @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "创建用户,为用户发送验证邮件,等待用户激活,若24小时内未激活需要重新注册", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 409, message = "用户名已存在"), @ApiResponse(code = 400, message = "用户属性校验失败") }) public void crea...
UserController { @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "创建用户,为用户发送验证邮件,等待用户激活,若24小时内未激活需要重新注册", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 409, message = "用户名已存在"), @ApiResponse(code = 400, message = "用户属性校验失败") }) public void crea...
UserController { @ResponseStatus(HttpStatus.CREATED) @RequestMapping(method = RequestMethod.POST) @ApiOperation(value = "创建用户,为用户发送验证邮件,等待用户激活,若24小时内未激活需要重新注册", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 409, message = "用户名已存在"), @ApiResponse(code = 400, message = "用户属性校验失败") }) public void crea...
@Test public void getUserAvatar() throws Exception { System.out.println(UserMode.valueOf("USERNAME")); }
@RequestMapping(value = "/{id}/avatar", method = RequestMethod.GET) @ApiOperation(value = "获取用户的头像图片", response = Byte.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "文件不存在"), @ApiResponse(code = 400, message = "文件传输失败") }) public void getUserAvatar(@PathVariable("id") Long id, HttpServletRequest req...
UserController { @RequestMapping(value = "/{id}/avatar", method = RequestMethod.GET) @ApiOperation(value = "获取用户的头像图片", response = Byte.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "文件不存在"), @ApiResponse(code = 400, message = "文件传输失败") }) public void getUserAvatar(@PathVariable("id") Long id, HttpS...
UserController { @RequestMapping(value = "/{id}/avatar", method = RequestMethod.GET) @ApiOperation(value = "获取用户的头像图片", response = Byte.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "文件不存在"), @ApiResponse(code = 400, message = "文件传输失败") }) public void getUserAvatar(@PathVariable("id") Long id, HttpS...
UserController { @RequestMapping(value = "/{id}/avatar", method = RequestMethod.GET) @ApiOperation(value = "获取用户的头像图片", response = Byte.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "文件不存在"), @ApiResponse(code = 400, message = "文件传输失败") }) public void getUserAvatar(@PathVariable("id") Long id, HttpS...
UserController { @RequestMapping(value = "/{id}/avatar", method = RequestMethod.GET) @ApiOperation(value = "获取用户的头像图片", response = Byte.class) @ApiResponses(value = { @ApiResponse(code = 404, message = "文件不存在"), @ApiResponse(code = 400, message = "文件传输失败") }) public void getUserAvatar(@PathVariable("id") Long id, HttpS...
@Test public void activate() throws Exception { }
@RequestMapping(value = "/{id}/activation", method = RequestMethod.GET) @ApiOperation(value = "用户激活,前置条件是用户已注册且在24小时内", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 401, message = "未注册或超时或激活码错误") }) public void activate(@PathVariable("id") @ApiParam(value = "用户Id", required = true) Long id, @Reque...
UserController { @RequestMapping(value = "/{id}/activation", method = RequestMethod.GET) @ApiOperation(value = "用户激活,前置条件是用户已注册且在24小时内", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 401, message = "未注册或超时或激活码错误") }) public void activate(@PathVariable("id") @ApiParam(value = "用户Id", required = true...
UserController { @RequestMapping(value = "/{id}/activation", method = RequestMethod.GET) @ApiOperation(value = "用户激活,前置条件是用户已注册且在24小时内", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 401, message = "未注册或超时或激活码错误") }) public void activate(@PathVariable("id") @ApiParam(value = "用户Id", required = true...
UserController { @RequestMapping(value = "/{id}/activation", method = RequestMethod.GET) @ApiOperation(value = "用户激活,前置条件是用户已注册且在24小时内", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 401, message = "未注册或超时或激活码错误") }) public void activate(@PathVariable("id") @ApiParam(value = "用户Id", required = true...
UserController { @RequestMapping(value = "/{id}/activation", method = RequestMethod.GET) @ApiOperation(value = "用户激活,前置条件是用户已注册且在24小时内", response = Void.class) @ApiResponses(value = { @ApiResponse(code = 401, message = "未注册或超时或激活码错误") }) public void activate(@PathVariable("id") @ApiParam(value = "用户Id", required = true...
@Test public void updateUser() throws Exception { }
@RequestMapping(method = RequestMethod.PUT) @PreAuthorize("#user.username == principal.username or hasRole('ADMIN')") @ApiOperation(value = "更新用户信息", response = Void.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = { @ApiResponse(code = 401, message = "未登录"), @ApiResponse(code = 404, message = "用...
UserController { @RequestMapping(method = RequestMethod.PUT) @PreAuthorize("#user.username == principal.username or hasRole('ADMIN')") @ApiOperation(value = "更新用户信息", response = Void.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = { @ApiResponse(code = 401, message = "未登录"), @ApiResponse(code = ...
UserController { @RequestMapping(method = RequestMethod.PUT) @PreAuthorize("#user.username == principal.username or hasRole('ADMIN')") @ApiOperation(value = "更新用户信息", response = Void.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = { @ApiResponse(code = 401, message = "未登录"), @ApiResponse(code = ...
UserController { @RequestMapping(method = RequestMethod.PUT) @PreAuthorize("#user.username == principal.username or hasRole('ADMIN')") @ApiOperation(value = "更新用户信息", response = Void.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = { @ApiResponse(code = 401, message = "未登录"), @ApiResponse(code = ...
UserController { @RequestMapping(method = RequestMethod.PUT) @PreAuthorize("#user.username == principal.username or hasRole('ADMIN')") @ApiOperation(value = "更新用户信息", response = Void.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = { @ApiResponse(code = 401, message = "未登录"), @ApiResponse(code = ...
@Test public void forgetPassword() throws Exception { }
@RequestMapping(value = "/{key}/password/reset_validation", method = RequestMethod.GET) @ApiOperation(value = "发送忘记密码的邮箱验证", notes = "属性可以是id,sername或email或手机号", response = UserDO.class) public void forgetPassword(@PathVariable("key") @ApiParam(value = "关键字", required = true) String key, @RequestParam("mode") @ApiParam...
UserController { @RequestMapping(value = "/{key}/password/reset_validation", method = RequestMethod.GET) @ApiOperation(value = "发送忘记密码的邮箱验证", notes = "属性可以是id,sername或email或手机号", response = UserDO.class) public void forgetPassword(@PathVariable("key") @ApiParam(value = "关键字", required = true) String key, @RequestParam(...
UserController { @RequestMapping(value = "/{key}/password/reset_validation", method = RequestMethod.GET) @ApiOperation(value = "发送忘记密码的邮箱验证", notes = "属性可以是id,sername或email或手机号", response = UserDO.class) public void forgetPassword(@PathVariable("key") @ApiParam(value = "关键字", required = true) String key, @RequestParam(...
UserController { @RequestMapping(value = "/{key}/password/reset_validation", method = RequestMethod.GET) @ApiOperation(value = "发送忘记密码的邮箱验证", notes = "属性可以是id,sername或email或手机号", response = UserDO.class) public void forgetPassword(@PathVariable("key") @ApiParam(value = "关键字", required = true) String key, @RequestParam(...
UserController { @RequestMapping(value = "/{key}/password/reset_validation", method = RequestMethod.GET) @ApiOperation(value = "发送忘记密码的邮箱验证", notes = "属性可以是id,sername或email或手机号", response = UserDO.class) public void forgetPassword(@PathVariable("key") @ApiParam(value = "关键字", required = true) String key, @RequestParam(...
@Test public void resetPassword() throws Exception { }
@RequestMapping(value = "/{id}/password", method = RequestMethod.PUT) @ApiOperation(value = "忘记密码后可以修改密码") public void resetPassword(@PathVariable("id") Long id, @RequestParam("forgetPasswordCode") @ApiParam(value = "验证码", required = true) String forgetPasswordCode, @RequestParam("password") @ApiParam(value = "新密码", re...
UserController { @RequestMapping(value = "/{id}/password", method = RequestMethod.PUT) @ApiOperation(value = "忘记密码后可以修改密码") public void resetPassword(@PathVariable("id") Long id, @RequestParam("forgetPasswordCode") @ApiParam(value = "验证码", required = true) String forgetPasswordCode, @RequestParam("password") @ApiParam(...
UserController { @RequestMapping(value = "/{id}/password", method = RequestMethod.PUT) @ApiOperation(value = "忘记密码后可以修改密码") public void resetPassword(@PathVariable("id") Long id, @RequestParam("forgetPasswordCode") @ApiParam(value = "验证码", required = true) String forgetPasswordCode, @RequestParam("password") @ApiParam(...
UserController { @RequestMapping(value = "/{id}/password", method = RequestMethod.PUT) @ApiOperation(value = "忘记密码后可以修改密码") public void resetPassword(@PathVariable("id") Long id, @RequestParam("forgetPasswordCode") @ApiParam(value = "验证码", required = true) String forgetPasswordCode, @RequestParam("password") @ApiParam(...
UserController { @RequestMapping(value = "/{id}/password", method = RequestMethod.PUT) @ApiOperation(value = "忘记密码后可以修改密码") public void resetPassword(@PathVariable("id") Long id, @RequestParam("forgetPasswordCode") @ApiParam(value = "验证码", required = true) String forgetPasswordCode, @RequestParam("password") @ApiParam(...
@Test public void isUsernameDuplicated() throws Exception { }
@RequestMapping(value = "/{username}/duplication", method = RequestMethod.GET) @ApiOperation(value = "查询用户名是否重复", response = Boolean.class) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public boolean isUsernameDuplicated(@PathVariable("username") String username) { if (service.findByUsername(usern...
UserController { @RequestMapping(value = "/{username}/duplication", method = RequestMethod.GET) @ApiOperation(value = "查询用户名是否重复", response = Boolean.class) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public boolean isUsernameDuplicated(@PathVariable("username") String username) { if (service.fin...
UserController { @RequestMapping(value = "/{username}/duplication", method = RequestMethod.GET) @ApiOperation(value = "查询用户名是否重复", response = Boolean.class) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public boolean isUsernameDuplicated(@PathVariable("username") String username) { if (service.fin...
UserController { @RequestMapping(value = "/{username}/duplication", method = RequestMethod.GET) @ApiOperation(value = "查询用户名是否重复", response = Boolean.class) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public boolean isUsernameDuplicated(@PathVariable("username") String username) { if (service.fin...
UserController { @RequestMapping(value = "/{username}/duplication", method = RequestMethod.GET) @ApiOperation(value = "查询用户名是否重复", response = Boolean.class) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public boolean isUsernameDuplicated(@PathVariable("username") String username) { if (service.fin...
@Test public void findAllUsers() throws Exception { }
@RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasRole('ADMIN')") @ApiOperation(value = "分页查询用户信息", response = PageInfo.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public PageInfo<UserDO> findAllUsers(@RequestParam("pageNum") @ApiParam...
UserController { @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasRole('ADMIN')") @ApiOperation(value = "分页查询用户信息", response = PageInfo.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public PageInfo<UserDO> findAllUsers(@RequestParam("pa...
UserController { @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasRole('ADMIN')") @ApiOperation(value = "分页查询用户信息", response = PageInfo.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public PageInfo<UserDO> findAllUsers(@RequestParam("pa...
UserController { @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasRole('ADMIN')") @ApiOperation(value = "分页查询用户信息", response = PageInfo.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public PageInfo<UserDO> findAllUsers(@RequestParam("pa...
UserController { @RequestMapping(method = RequestMethod.GET) @PreAuthorize("hasRole('ADMIN')") @ApiOperation(value = "分页查询用户信息", response = PageInfo.class, authorizations = {@Authorization("登录权限")}) @ApiResponses(value = {@ApiResponse(code = 401, message = "未登录")}) public PageInfo<UserDO> findAllUsers(@RequestParam("pa...
@Test public void testEscapingOfNull() { assertThat(tool.escape(null), is(nullValue())); }
public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output.replace("§", "\\S...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
@Test public void testEscaping() { assertThat(tool.escape("\\"), is("\\textbackslash ")); assertThat(tool.escape("<"), is("\\textless ")); assertThat(tool.escape(">"), is("\\textgreater ")); assertThat(tool.escape("§"), is("\\S ")); assertThat(tool.escape("&"), is("\\&")); assertThat(tool.escape("%"), is("\\%")); asser...
public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output.replace("§", "\\S...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
@Test public void testMultipleCharacters() { final String expected = "!\"\\S '\\$\\%\\&/()=¿?[]\\{\\}\\euro @\\textasciicircum \\textasciitilde \\textbackslash \\#ßôâéè\\textless \\textgreater "; assertThat(tool.escape("!\"§'$%&/()=¿?[]{}€@^~\\#ßôâéè<>"), is(expected)); }
public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output.replace("§", "\\S...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
LatexEscapeTool { public String escape(final String input) { if (input == null) { return null; } String output = input; output = output.replace("\\", "\\textbackslash "); output = output.replace("€", "\\euro "); output = output.replace("<", "\\textless "); output = output.replace(">", "\\textgreater "); output = output...
@Test(expected = NullPointerException.class) public void testNullKey() { new LatexContext().add(null, null); fail(); }
public LatexContext add(final String key, final Object value) { requireNonNull(key, "key must not be null"); context.put(key, value); return this; }
LatexContext { public LatexContext add(final String key, final Object value) { requireNonNull(key, "key must not be null"); context.put(key, value); return this; } }
LatexContext { public LatexContext add(final String key, final Object value) { requireNonNull(key, "key must not be null"); context.put(key, value); return this; } }
LatexContext { public LatexContext add(final String key, final Object value) { requireNonNull(key, "key must not be null"); context.put(key, value); return this; } LatexContext add(final String key, final Object value); Set<String> keys(); Map<String, Object> asMap(); }
LatexContext { public LatexContext add(final String key, final Object value) { requireNonNull(key, "key must not be null"); context.put(key, value); return this; } LatexContext add(final String key, final Object value); Set<String> keys(); Map<String, Object> asMap(); }
@Test public void processTemplate() { LatexTemplate template = new LatexTemplate("${keyToReplace}"); LatexContext context = new LatexContext(); context.add("keyToReplace", "value"); String result = template.populateFrom(context); assertThat(result, is("value")); }
public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); }
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } }
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } LatexTemplate(final String templa...
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } LatexTemplate(final String templa...
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } LatexTemplate(final String templa...
@Test(expected = NullPointerException.class) public void processNullContext() { new LatexTemplate("").populateFrom(null); fail(); }
public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); }
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } }
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } LatexTemplate(final String templa...
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } LatexTemplate(final String templa...
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } LatexTemplate(final String templa...
@Test(expected = LatexTemplateProcessingException.class) public void processIncompleteTemplate() { LatexTemplate template = new LatexTemplate("${incompleteTemplate"); template.populateFrom(new LatexContext()); fail(); }
public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); }
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } }
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } LatexTemplate(final String templa...
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } LatexTemplate(final String templa...
LatexTemplate { public final String populateFrom(final LatexContext context) { requireNonNull(context); final VelocityEngine velocityEngine = initializeEngine(); final VelocityContext velocityContext = prepareContext(context); return evaluateTemplate(velocityContext, velocityEngine); } LatexTemplate(final String templa...
@Test public void simpleAggregation() throws UnknownHostException { List<String> vals = generateRandomAlphaNumericValues(); for (int i = 0; i < 100; i++) { if (i < 50) collection.insert(new BasicDBObject("manufacturer", vals.get(0))); else if(i < 75 ) collection.insert(new BasicDBObject("manufacturer", vals.get(1))); e...
public Iterator<DBObject> simpleAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("num_products"); builder.add("$sum", 1); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iterator(); }
AggregationExample { public Iterator<DBObject> simpleAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("num_products"); builder.add("$sum", 1); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().i...
AggregationExample { public Iterator<DBObject> simpleAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("num_products"); builder.add("$sum", 1); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().i...
AggregationExample { public Iterator<DBObject> simpleAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("num_products"); builder.add("$sum", 1); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().i...
AggregationExample { public Iterator<DBObject> simpleAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("num_products"); builder.add("$sum", 1); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().i...
@Test public void sortTest() { DBCollection zipsCollection = client.getDB("states").getCollection("zips"); agg.setCollection(zipsCollection); Iterator<DBObject> iter = agg.sort(); while(iter.hasNext()) { System.out.println(iter.next()); } }
public Iterator<DBObject> sort() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder project = new BasicDBObjectB...
AggregationExample { public Iterator<DBObject> sort() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder project...
AggregationExample { public Iterator<DBObject> sort() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder project...
AggregationExample { public Iterator<DBObject> sort() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder project...
AggregationExample { public Iterator<DBObject> sort() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder project...
@Test public void limitAndSkipTest() { DBCollection zipsCollection = client.getDB("states").getCollection("zips"); agg.setCollection(zipsCollection); Iterator<DBObject> iter = agg.limitAndSkip(); while(iter.hasNext()) { System.out.println(iter.next()); } }
public Iterator<DBObject> limitAndSkip() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder project = new BasicD...
AggregationExample { public Iterator<DBObject> limitAndSkip() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder...
AggregationExample { public Iterator<DBObject> limitAndSkip() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder...
AggregationExample { public Iterator<DBObject> limitAndSkip() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder...
AggregationExample { public Iterator<DBObject> limitAndSkip() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.pop(); BasicDBObjectBuilder...
@Test public void unwindTest() { DBCollection postsCollection = client.getDB("blog").getCollection("posts"); agg.setCollection(postsCollection); Iterator<DBObject> iter = agg.unwind(); while(iter.hasNext()) { System.out.println(iter.next()); } }
public Iterator<DBObject> unwind() { BasicDBObject unwind = new BasicDBObject("$unwind", "$tags"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$tags"); group.push("count"); group.add("$sum", 1); group.pop(); group.pop(); BasicDBObjectBuilder sort = new BasicDBObjectB...
AggregationExample { public Iterator<DBObject> unwind() { BasicDBObject unwind = new BasicDBObject("$unwind", "$tags"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$tags"); group.push("count"); group.add("$sum", 1); group.pop(); group.pop(); BasicDBObjectBuilder sort...
AggregationExample { public Iterator<DBObject> unwind() { BasicDBObject unwind = new BasicDBObject("$unwind", "$tags"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$tags"); group.push("count"); group.add("$sum", 1); group.pop(); group.pop(); BasicDBObjectBuilder sort...
AggregationExample { public Iterator<DBObject> unwind() { BasicDBObject unwind = new BasicDBObject("$unwind", "$tags"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$tags"); group.push("count"); group.add("$sum", 1); group.pop(); group.pop(); BasicDBObjectBuilder sort...
AggregationExample { public Iterator<DBObject> unwind() { BasicDBObject unwind = new BasicDBObject("$unwind", "$tags"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$tags"); group.push("count"); group.add("$sum", 1); group.pop(); group.pop(); BasicDBObjectBuilder sort...
@Test public void doubleUnwindTest() { DBCollection inventoryCollection = db.getCollection("inventory"); agg.setCollection(inventoryCollection); inventoryCollection.insert(new BasicDBObject("name","Polo Shirt").append("sizes",new String[] {"Small", "Medium","Large"}).append("colors", new String[] {"navy","white","oragn...
public Iterator<DBObject> doubleUnwind() { BasicDBObject unwindSizes = new BasicDBObject("$unwind", "$sizes"); BasicDBObject unwindColors = new BasicDBObject("$unwind", "$colors"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.push("_id"); group.add("size", "$sizes"); group.add("c...
AggregationExample { public Iterator<DBObject> doubleUnwind() { BasicDBObject unwindSizes = new BasicDBObject("$unwind", "$sizes"); BasicDBObject unwindColors = new BasicDBObject("$unwind", "$colors"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.push("_id"); group.add("size", "$...
AggregationExample { public Iterator<DBObject> doubleUnwind() { BasicDBObject unwindSizes = new BasicDBObject("$unwind", "$sizes"); BasicDBObject unwindColors = new BasicDBObject("$unwind", "$colors"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.push("_id"); group.add("size", "$...
AggregationExample { public Iterator<DBObject> doubleUnwind() { BasicDBObject unwindSizes = new BasicDBObject("$unwind", "$sizes"); BasicDBObject unwindColors = new BasicDBObject("$unwind", "$colors"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.push("_id"); group.add("size", "$...
AggregationExample { public Iterator<DBObject> doubleUnwind() { BasicDBObject unwindSizes = new BasicDBObject("$unwind", "$sizes"); BasicDBObject unwindColors = new BasicDBObject("$unwind", "$colors"); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.push("_id"); group.add("size", "$...
@Test public void compoundGrouping() { List<String> manufacturers = generateRandomAlphaNumericValues(); List<String> categories = generateRandomAlphaNumericValues(); for (int i = 0; i < 100; i++) { if (i < 50) collection.insert(new BasicDBObject("manufacturer", manufacturers.get(0)).append("category", categories.get(Ra...
public Iterator<DBObject> compoundAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("manufacturer", "$manufacturer"); builder.add("category", "$category"); builder.pop(); builder.push("num_products"); builder.add("$sum", 1); builder.pop()...
AggregationExample { public Iterator<DBObject> compoundAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("manufacturer", "$manufacturer"); builder.add("category", "$category"); builder.pop(); builder.push("num_products"); builder.add("$su...
AggregationExample { public Iterator<DBObject> compoundAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("manufacturer", "$manufacturer"); builder.add("category", "$category"); builder.pop(); builder.push("num_products"); builder.add("$su...
AggregationExample { public Iterator<DBObject> compoundAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("manufacturer", "$manufacturer"); builder.add("category", "$category"); builder.pop(); builder.push("num_products"); builder.add("$su...
AggregationExample { public Iterator<DBObject> compoundAggregation() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("manufacturer", "$manufacturer"); builder.add("category", "$category"); builder.pop(); builder.push("num_products"); builder.add("$su...
@Test public void usingSumTest() { List<String> manufacturers = generateRandomAlphaNumericValues(); List<Double> prices = generateRandomDoubleValues(); for (int i = 0; i < 100; i++) { if (i < 50) collection.insert(new BasicDBObject("manufacturer", manufacturers.get(0)).append("price", prices.get(RandomUtils.nextInt(pri...
public Iterator<DBObject> sumPrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("sum_prices"); builder.add("$sum", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iterator(); }
AggregationExample { public Iterator<DBObject> sumPrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("sum_prices"); builder.add("$sum", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iter...
AggregationExample { public Iterator<DBObject> sumPrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("sum_prices"); builder.add("$sum", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iter...
AggregationExample { public Iterator<DBObject> sumPrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("sum_prices"); builder.add("$sum", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iter...
AggregationExample { public Iterator<DBObject> sumPrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$manufacturer"); builder.push("sum_prices"); builder.add("$sum", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iter...
@Test public void usingAvgTest() { List<String> categories = generateRandomAlphaNumericValues(); List<Double> prices = generateRandomDoubleValues(); for (int i = 0; i < 100; i++) { if (i < 50) collection.insert(new BasicDBObject("category", categories.get(0)).append("price", prices.get(RandomUtils.nextInt(prices.size()...
public Iterator<DBObject> averagePrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$category"); builder.push("sum_prices"); builder.add("$avg", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iterator(); }
AggregationExample { public Iterator<DBObject> averagePrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$category"); builder.push("sum_prices"); builder.add("$avg", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iter...
AggregationExample { public Iterator<DBObject> averagePrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$category"); builder.push("sum_prices"); builder.add("$avg", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iter...
AggregationExample { public Iterator<DBObject> averagePrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$category"); builder.push("sum_prices"); builder.add("$avg", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iter...
AggregationExample { public Iterator<DBObject> averagePrices() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.add("_id", "$category"); builder.push("sum_prices"); builder.add("$avg", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get()).results().iter...
@Test public void addToSetTest() { List<String> manufacturers = generateRandomAlphaNumericValues(); List<String> categories = generateRandomAlphaNumericValues(); for (int i = 0; i < 100; i++) { if (i < 50) collection.insert(new BasicDBObject("manufacturer", manufacturers.get(0)).append("category", categories.get(Random...
public Iterator<DBObject> addToSet() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$addToSet", "$category"); builder.pop(); builder.pop(); return col.aggregate(build...
AggregationExample { public Iterator<DBObject> addToSet() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$addToSet", "$category"); builder.pop(); builder.pop(); retur...
AggregationExample { public Iterator<DBObject> addToSet() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$addToSet", "$category"); builder.pop(); builder.pop(); retur...
AggregationExample { public Iterator<DBObject> addToSet() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$addToSet", "$category"); builder.pop(); builder.pop(); retur...
AggregationExample { public Iterator<DBObject> addToSet() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$addToSet", "$category"); builder.pop(); builder.pop(); retur...
@Test public void pushTest() { List<String> manufacturers = generateRandomAlphaNumericValues(); List<String> categories = generateRandomAlphaNumericValues(); for (int i = 0; i < 100; i++) { if (i < 50) collection.insert(new BasicDBObject("manufacturer", manufacturers.get(0)).append("category", categories.get(RandomUtil...
public Iterator<DBObject> push() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$push", "$category"); builder.pop(); builder.pop(); return col.aggregate(builder.get()...
AggregationExample { public Iterator<DBObject> push() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$push", "$category"); builder.pop(); builder.pop(); return col.ag...
AggregationExample { public Iterator<DBObject> push() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$push", "$category"); builder.pop(); builder.pop(); return col.ag...
AggregationExample { public Iterator<DBObject> push() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$push", "$category"); builder.pop(); builder.pop(); return col.ag...
AggregationExample { public Iterator<DBObject> push() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("categories"); builder.add("$push", "$category"); builder.pop(); builder.pop(); return col.ag...
@Test public void maxAndMinTest() { List<String> manufacturers = generateRandomAlphaNumericValues(); List<Double> prices = generateRandomDoubleValues(); for (int i = 0; i < 100; i++) { if (i < 50) collection.insert(new BasicDBObject("manufacturer", manufacturers.get(0)).append("price", prices.get(RandomUtils.nextInt(pr...
public Iterator<DBObject> maxPrice() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("maxprice"); builder.add("$max", "$price"); builder.pop(); builder.pop(); return col.aggregate(builder.get())....
AggregationExample { public Iterator<DBObject> maxPrice() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("maxprice"); builder.add("$max", "$price"); builder.pop(); builder.pop(); return col.aggr...
AggregationExample { public Iterator<DBObject> maxPrice() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("maxprice"); builder.add("$max", "$price"); builder.pop(); builder.pop(); return col.aggr...
AggregationExample { public Iterator<DBObject> maxPrice() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("maxprice"); builder.add("$max", "$price"); builder.pop(); builder.pop(); return col.aggr...
AggregationExample { public Iterator<DBObject> maxPrice() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$group"); builder.push("_id"); builder.add("maker", "$manufacturer"); builder.pop(); builder.push("maxprice"); builder.add("$max", "$price"); builder.pop(); builder.pop(); return col.aggr...
@Test public void doubleGroupStages() { DBCollection grades = db.getCollection("grades"); agg.setCollection(grades); int[] class_id = {1,2,3,4,5}; int[] student_id = {100,101,102,103,104,105}; for(int cls = 0; cls < class_id.length; cls++) { for(int student = 0; student < student_id.length; student++) { grades.insert(n...
public Iterator<DBObject> doubleGroupStages() { BasicDBObjectBuilder group_1 = new BasicDBObjectBuilder(); group_1.push("$group"); group_1.push("_id"); group_1.add("class_id", "$class_id"); group_1.add("student_id", "$student_id"); group_1.pop(); group_1.push("average"); group_1.add("$avg", "$score"); group_1.pop(); gr...
AggregationExample { public Iterator<DBObject> doubleGroupStages() { BasicDBObjectBuilder group_1 = new BasicDBObjectBuilder(); group_1.push("$group"); group_1.push("_id"); group_1.add("class_id", "$class_id"); group_1.add("student_id", "$student_id"); group_1.pop(); group_1.push("average"); group_1.add("$avg", "$score...
AggregationExample { public Iterator<DBObject> doubleGroupStages() { BasicDBObjectBuilder group_1 = new BasicDBObjectBuilder(); group_1.push("$group"); group_1.push("_id"); group_1.add("class_id", "$class_id"); group_1.add("student_id", "$student_id"); group_1.pop(); group_1.push("average"); group_1.add("$avg", "$score...
AggregationExample { public Iterator<DBObject> doubleGroupStages() { BasicDBObjectBuilder group_1 = new BasicDBObjectBuilder(); group_1.push("$group"); group_1.push("_id"); group_1.add("class_id", "$class_id"); group_1.add("student_id", "$student_id"); group_1.pop(); group_1.push("average"); group_1.add("$avg", "$score...
AggregationExample { public Iterator<DBObject> doubleGroupStages() { BasicDBObjectBuilder group_1 = new BasicDBObjectBuilder(); group_1.push("$group"); group_1.push("_id"); group_1.add("class_id", "$class_id"); group_1.add("student_id", "$student_id"); group_1.pop(); group_1.push("average"); group_1.add("$avg", "$score...
@Test public void projectTest() { collection.insert(new BasicDBObject("manufacturer", "Apple").append("price", 2000.01).append("category", "Lap Top").append("name", "MacBookAir")); Iterator<DBObject> iter = agg.project(); while(iter.hasNext()) { System.out.println(iter.next()); } collection.drop(); }
public Iterator<DBObject> project() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$project"); builder.add("_id", 0); builder.push("maker"); builder.add("$toLower", "$manufacturer"); builder.pop(); builder.push("details"); builder.add("category", "$category"); builder.push("price"); builder....
AggregationExample { public Iterator<DBObject> project() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$project"); builder.add("_id", 0); builder.push("maker"); builder.add("$toLower", "$manufacturer"); builder.pop(); builder.push("details"); builder.add("category", "$category"); builder.pu...
AggregationExample { public Iterator<DBObject> project() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$project"); builder.add("_id", 0); builder.push("maker"); builder.add("$toLower", "$manufacturer"); builder.pop(); builder.push("details"); builder.add("category", "$category"); builder.pu...
AggregationExample { public Iterator<DBObject> project() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$project"); builder.add("_id", 0); builder.push("maker"); builder.add("$toLower", "$manufacturer"); builder.pop(); builder.push("details"); builder.add("category", "$category"); builder.pu...
AggregationExample { public Iterator<DBObject> project() { BasicDBObjectBuilder builder = new BasicDBObjectBuilder(); builder.push("$project"); builder.add("_id", 0); builder.push("maker"); builder.add("$toLower", "$manufacturer"); builder.pop(); builder.push("details"); builder.add("category", "$category"); builder.pu...
@Test public void matchTest() { DBCollection zipsCollection = client.getDB("states").getCollection("zips"); agg.setCollection(zipsCollection); Iterator<DBObject> iter = agg.match(); while(iter.hasNext()) { System.out.println(iter.next()); } }
public Iterator<DBObject> match() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.push("zip_codes"); group.add("$addToSet", "$_id"); grou...
AggregationExample { public Iterator<DBObject> match() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.push("zip_codes"); group.add("$add...
AggregationExample { public Iterator<DBObject> match() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.push("zip_codes"); group.add("$add...
AggregationExample { public Iterator<DBObject> match() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.push("zip_codes"); group.add("$add...
AggregationExample { public Iterator<DBObject> match() { BasicDBObjectBuilder match = buildMatchDBObject(); BasicDBObjectBuilder group = new BasicDBObjectBuilder(); group.push("$group"); group.add("_id", "$city"); group.push("population"); group.add("$sum", "$pop"); group.pop(); group.push("zip_codes"); group.add("$add...
@Test public void testExit0() { InputStream inputStream = new ByteArrayInputStream(OUTPUT_EXIT0.getBytes(StandardCharsets.UTF_8)); int exitCode = Exec.parseExitCode(client, inputStream); assertEquals(0, exitCode); }
static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if ...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
@Test public void testCopyShifting() throws Exception { DefaultDelayingQueue<String> queue = new DefaultDelayingQueue<>(); final String first = "foo"; final String second = "bar"; final String third = "baz"; queue.addAfter(first, Duration.ofSeconds(1)); queue.addAfter(second, Duration.ofMillis(500)); queue.addAfter(thi...
public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAddQueue.offer(entry); }
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAdd...
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAdd...
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAdd...
DefaultDelayingQueue extends DefaultWorkQueue<T> implements DelayingQueue<T> { public void addAfter(T item, Duration duration) { if (super.isShuttingDown()) { return; } if (duration.isZero()) { super.add(item); return; } WaitForEntry<T> entry = new WaitForEntry<>(item, duration.addTo(Instant.now())); this.waitingForAdd...
@Test public void testMaxOfRateLimiter() { RateLimiter<String> rateLimiter = new MaxOfRateLimiter<>( new ItemFastSlowRateLimiter<>(Duration.ofMillis(5), Duration.ofSeconds(3), 3), new ItemExponentialFailureRateLimiter<>(Duration.ofMillis(1), Duration.ofSeconds(1))); assertEquals(Duration.ofMillis(5), rateLimiter.when("...
public MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters) { this.rateLimiters = rateLimiters; }
MaxOfRateLimiter implements RateLimiter<T> { public MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters) { this.rateLimiters = rateLimiters; } }
MaxOfRateLimiter implements RateLimiter<T> { public MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters) { this.rateLimiters = rateLimiters; } MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters); @SafeVarargs @SuppressWarnings("varargs") MaxOfRateLimiter(RateLimiter<T>... rateLimiters); }
MaxOfRateLimiter implements RateLimiter<T> { public MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters) { this.rateLimiters = rateLimiters; } MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters); @SafeVarargs @SuppressWarnings("varargs") MaxOfRateLimiter(RateLimiter<T>... rateLimiters); @Override Duration when(T item);...
MaxOfRateLimiter implements RateLimiter<T> { public MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters) { this.rateLimiters = rateLimiters; } MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters); @SafeVarargs @SuppressWarnings("varargs") MaxOfRateLimiter(RateLimiter<T>... rateLimiters); @Override Duration when(T item);...
@Test public void testDefaultRateLimiter() { RateLimiter<String> rateLimiter = new DefaultControllerRateLimiter<>(); assertEquals(Duration.ofMillis(5), rateLimiter.when("one")); assertEquals(Duration.ofMillis(10), rateLimiter.when("one")); assertEquals(Duration.ofMillis(20), rateLimiter.when("one")); for (int i = 0; i ...
@Override public Duration when(T item) { Duration max = Duration.ZERO; for (RateLimiter<T> r : rateLimiters) { Duration current = r.when(item); if (current.compareTo(max) > 0) { max = current; } } return max; }
MaxOfRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { Duration max = Duration.ZERO; for (RateLimiter<T> r : rateLimiters) { Duration current = r.when(item); if (current.compareTo(max) > 0) { max = current; } } return max; } }
MaxOfRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { Duration max = Duration.ZERO; for (RateLimiter<T> r : rateLimiters) { Duration current = r.when(item); if (current.compareTo(max) > 0) { max = current; } } return max; } MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters); @SafeVararg...
MaxOfRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { Duration max = Duration.ZERO; for (RateLimiter<T> r : rateLimiters) { Duration current = r.when(item); if (current.compareTo(max) > 0) { max = current; } } return max; } MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters); @SafeVararg...
MaxOfRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { Duration max = Duration.ZERO; for (RateLimiter<T> r : rateLimiters) { Duration current = r.when(item); if (current.compareTo(max) > 0) { max = current; } } return max; } MaxOfRateLimiter(List<RateLimiter<T>> rateLimiters); @SafeVararg...
@Test public void testBucketRateLimiterBasic() { RateLimiter<String> rateLimiter = new BucketRateLimiter<>(2, 1, Duration.ofMinutes(10)); assertEquals(Duration.ZERO, rateLimiter.when("one")); assertEquals(Duration.ZERO, rateLimiter.when("one")); Duration waitDuration = rateLimiter.when("one"); Duration expectDuration =...
@Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); }
BucketRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); } }
BucketRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); } BucketRateLimiter(long capacity, long tokensGeneratedInPeriod, Duration period); }
BucketRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); } BucketRateLimiter(long capacity, long tokensGeneratedInPeriod, Duration period); @Override Duration when(T item); @Override void fo...
BucketRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); } BucketRateLimiter(long capacity, long tokensGeneratedInPeriod, Duration period); @Override Duration when(T item); @Override void fo...
@Test public void testBucketRateLimiterTokenAdded() throws InterruptedException { RateLimiter<String> rateLimiter = new BucketRateLimiter<>(2, 1, Duration.ofSeconds(2)); assertEquals(Duration.ZERO, rateLimiter.when("one")); assertEquals(Duration.ZERO, rateLimiter.when("one")); Duration waitDuration = rateLimiter.when("...
@Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); }
BucketRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); } }
BucketRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); } BucketRateLimiter(long capacity, long tokensGeneratedInPeriod, Duration period); }
BucketRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); } BucketRateLimiter(long capacity, long tokensGeneratedInPeriod, Duration period); @Override Duration when(T item); @Override void fo...
BucketRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long overdraftNanos = bucket.consumeIgnoringRateLimits(1); return Duration.ofNanos(overdraftNanos); } BucketRateLimiter(long capacity, long tokensGeneratedInPeriod, Duration period); @Override Duration when(T item); @Override void fo...
@Test public void testItemExponentialFailureRateLimiter() { RateLimiter<String> rateLimiter = new ItemExponentialFailureRateLimiter<>(Duration.ofMillis(1), Duration.ofSeconds(1)); assertEquals(Duration.ofMillis(1), rateLimiter.when("one")); assertEquals(Duration.ofMillis(2), rateLimiter.when("one")); assertEquals(Durat...
public ItemExponentialFailureRateLimiter(Duration baseDelay, Duration maxDelay) { this.baseDelay = baseDelay; this.maxDelay = maxDelay; failures = AtomicLongMap.create(); }
ItemExponentialFailureRateLimiter implements RateLimiter<T> { public ItemExponentialFailureRateLimiter(Duration baseDelay, Duration maxDelay) { this.baseDelay = baseDelay; this.maxDelay = maxDelay; failures = AtomicLongMap.create(); } }
ItemExponentialFailureRateLimiter implements RateLimiter<T> { public ItemExponentialFailureRateLimiter(Duration baseDelay, Duration maxDelay) { this.baseDelay = baseDelay; this.maxDelay = maxDelay; failures = AtomicLongMap.create(); } ItemExponentialFailureRateLimiter(Duration baseDelay, Duration maxDelay); }
ItemExponentialFailureRateLimiter implements RateLimiter<T> { public ItemExponentialFailureRateLimiter(Duration baseDelay, Duration maxDelay) { this.baseDelay = baseDelay; this.maxDelay = maxDelay; failures = AtomicLongMap.create(); } ItemExponentialFailureRateLimiter(Duration baseDelay, Duration maxDelay); @Override D...
ItemExponentialFailureRateLimiter implements RateLimiter<T> { public ItemExponentialFailureRateLimiter(Duration baseDelay, Duration maxDelay) { this.baseDelay = baseDelay; this.maxDelay = maxDelay; failures = AtomicLongMap.create(); } ItemExponentialFailureRateLimiter(Duration baseDelay, Duration maxDelay); @Override D...
@Test public void testItemExponentialFailureRateLimiterOverFlow() { RateLimiter<String> rateLimiter = new ItemExponentialFailureRateLimiter<>(Duration.ofMillis(1), Duration.ofSeconds(1000)); for (int i = 0; i < 5; i++) { rateLimiter.when("one"); } assertEquals(Duration.ofMillis(32), rateLimiter.when("one")); for (int i...
@Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; }
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } }
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } ItemExponentialFailureRateLimiter(Duration baseDelay, Du...
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } ItemExponentialFailureRateLimiter(Duration baseDelay, Du...
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } ItemExponentialFailureRateLimiter(Duration baseDelay, Du...
@Test public void testNegativeBaseDelay() { RateLimiter<String> rateLimiter = new ItemExponentialFailureRateLimiter<>(Duration.ofMillis(-1), Duration.ofSeconds(1000)); for (int i = 0; i < 5; i++) { rateLimiter.when("one"); } assertEquals(Duration.ofMillis(-32), rateLimiter.when("one")); for (int i = 0; i < 1000; i++) {...
@Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; }
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } }
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } ItemExponentialFailureRateLimiter(Duration baseDelay, Du...
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } ItemExponentialFailureRateLimiter(Duration baseDelay, Du...
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } ItemExponentialFailureRateLimiter(Duration baseDelay, Du...
@Test public void testNegativeMaxDelay() { RateLimiter<String> rateLimiter = new ItemExponentialFailureRateLimiter<>(Duration.ofMillis(1), Duration.ofSeconds(-1000)); assertEquals(Duration.ofSeconds(-1000), rateLimiter.when("one")); assertEquals(Duration.ofSeconds(-1000), rateLimiter.when("one")); assertEquals(Duration...
@Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; }
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } }
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } ItemExponentialFailureRateLimiter(Duration baseDelay, Du...
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } ItemExponentialFailureRateLimiter(Duration baseDelay, Du...
ItemExponentialFailureRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long exp = failures.getAndIncrement(item); long d = maxDelay.toMillis() >> exp; return d > baseDelay.toMillis() ? baseDelay.multipliedBy(1 << exp) : maxDelay; } ItemExponentialFailureRateLimiter(Duration baseDelay, Du...
@Test public void testNegativeOrZeroAttempts() { RateLimiter<String> rateLimiter = new ItemFastSlowRateLimiter<>(Duration.ofMillis(5), Duration.ofSeconds(10), -1); assertEquals(Duration.ofSeconds(10), rateLimiter.when("one")); assertEquals(Duration.ofSeconds(10), rateLimiter.when("one")); assertEquals(Duration.ofSecond...
@Override public Duration when(T item) { long attempts = failures.incrementAndGet(item); if (attempts <= maxFastAttempts) { return fastDelay; } return slowDelay; }
ItemFastSlowRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long attempts = failures.incrementAndGet(item); if (attempts <= maxFastAttempts) { return fastDelay; } return slowDelay; } }
ItemFastSlowRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long attempts = failures.incrementAndGet(item); if (attempts <= maxFastAttempts) { return fastDelay; } return slowDelay; } ItemFastSlowRateLimiter(Duration fastDelay, Duration slowDelay, int maxFastAttempts); }
ItemFastSlowRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long attempts = failures.incrementAndGet(item); if (attempts <= maxFastAttempts) { return fastDelay; } return slowDelay; } ItemFastSlowRateLimiter(Duration fastDelay, Duration slowDelay, int maxFastAttempts); @Override Duration...
ItemFastSlowRateLimiter implements RateLimiter<T> { @Override public Duration when(T item) { long attempts = failures.incrementAndGet(item); if (attempts <= maxFastAttempts) { return fastDelay; } return slowDelay; } ItemFastSlowRateLimiter(Duration fastDelay, Duration slowDelay, int maxFastAttempts); @Override Duration...
@Test public void testLoad() { for (int i = 0; i < kinds.length; i++) { String className = classNames[i]; try { Object obj = Yaml.load( new StringReader(input.replace("XXXX", kinds[i]).replace("YYYY", apiVersions[i]))); Method m = obj.getClass().getMethod("getMetadata"); V1ObjectMeta metadata = (V1ObjectMeta) m.invoke(...
public static Object load(String content) throws IOException { return load(new StringReader(content)); }
Yaml { public static Object load(String content) throws IOException { return load(new StringReader(content)); } }
Yaml { public static Object load(String content) throws IOException { return load(new StringReader(content)); } }
Yaml { public static Object load(String content) throws IOException { return load(new StringReader(content)); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> clazz); static T loadAs(Re...
Yaml { public static Object load(String content) throws IOException { return load(new StringReader(content)); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> clazz); static T loadAs(Re...
@Test public void testLeaderElectingController() throws ApiException { AtomicReference<LeaderElectionRecord> record = new AtomicReference<>(); record.set(new LeaderElectionRecord()); when(mockLock.identity()).thenReturn("foo"); doAnswer(invocationOnMock -> record.get()).when(mockLock).get(); doAnswer( invocationOnMock ...
public LeaderElectingController(LeaderElector leaderElector, Controller delegateController) { this.delegateController = delegateController; this.leaderElector = leaderElector; }
LeaderElectingController implements Controller { public LeaderElectingController(LeaderElector leaderElector, Controller delegateController) { this.delegateController = delegateController; this.leaderElector = leaderElector; } }
LeaderElectingController implements Controller { public LeaderElectingController(LeaderElector leaderElector, Controller delegateController) { this.delegateController = delegateController; this.leaderElector = leaderElector; } LeaderElectingController(LeaderElector leaderElector, Controller delegateController); }
LeaderElectingController implements Controller { public LeaderElectingController(LeaderElector leaderElector, Controller delegateController) { this.delegateController = delegateController; this.leaderElector = leaderElector; } LeaderElectingController(LeaderElector leaderElector, Controller delegateController); @Overri...
LeaderElectingController implements Controller { public LeaderElectingController(LeaderElector leaderElector, Controller delegateController) { this.delegateController = delegateController; this.leaderElector = leaderElector; } LeaderElectingController(LeaderElector leaderElector, Controller delegateController); @Overri...
@Test(expected = IllegalStateException.class) public void testDummyBuildShouldFail() { ControllerBuilder.defaultBuilder(informerFactory).build(); }
public Controller build() throws IllegalStateException { if (this.reconciler == null) { throw new IllegalStateException("Missing reconciler when building controller."); } DefaultController controller = new DefaultController( this.reconciler, this.workQueue, this.readyFuncs.stream().toArray(Supplier[]::new)); controller...
DefaultControllerBuilder { public Controller build() throws IllegalStateException { if (this.reconciler == null) { throw new IllegalStateException("Missing reconciler when building controller."); } DefaultController controller = new DefaultController( this.reconciler, this.workQueue, this.readyFuncs.stream().toArray(Su...
DefaultControllerBuilder { public Controller build() throws IllegalStateException { if (this.reconciler == null) { throw new IllegalStateException("Missing reconciler when building controller."); } DefaultController controller = new DefaultController( this.reconciler, this.workQueue, this.readyFuncs.stream().toArray(Su...
DefaultControllerBuilder { public Controller build() throws IllegalStateException { if (this.reconciler == null) { throw new IllegalStateException("Missing reconciler when building controller."); } DefaultController controller = new DefaultController( this.reconciler, this.workQueue, this.readyFuncs.stream().toArray(Su...
DefaultControllerBuilder { public Controller build() throws IllegalStateException { if (this.reconciler == null) { throw new IllegalStateException("Missing reconciler when building controller."); } DefaultController controller = new DefaultController( this.reconciler, this.workQueue, this.readyFuncs.stream().toArray(Su...
@Test public void testDrainNodeNoPods() throws KubectlException, IOException { wireMockRule.stubFor( patch(urlPathEqualTo("/api/v1/nodes/node1")) .willReturn( aResponse().withStatus(200).withBody("{\"metadata\": { \"name\": \"node1\" } }"))); wireMockRule.stubFor( get(urlPathEqualTo("/api/v1/pods")) .withQueryParam("fi...
@Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } }
KubectlDrain extends KubectlCordon { @Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } } }
KubectlDrain extends KubectlCordon { @Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } } KubectlDrain(); }
KubectlDrain extends KubectlCordon { @Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } } KubectlDrain(); KubectlDrain gracePeriod(int gracePeriodSeconds); KubectlDrain force(); KubectlDrain ignoreDaemonSets(); ...
KubectlDrain extends KubectlCordon { @Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } } KubectlDrain(); KubectlDrain gracePeriod(int gracePeriodSeconds); KubectlDrain force(); KubectlDrain ignoreDaemonSets(); ...
@Test public void testDrainNodePods() throws KubectlException, IOException { wireMockRule.stubFor( patch(urlPathEqualTo("/api/v1/nodes/node1")) .willReturn( aResponse().withStatus(200).withBody("{\"metadata\": { \"name\": \"node1\" } }"))); wireMockRule.stubFor( get(urlPathEqualTo("/api/v1/pods")) .withQueryParam("fiel...
@Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } }
KubectlDrain extends KubectlCordon { @Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } } }
KubectlDrain extends KubectlCordon { @Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } } KubectlDrain(); }
KubectlDrain extends KubectlCordon { @Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } } KubectlDrain(); KubectlDrain gracePeriod(int gracePeriodSeconds); KubectlDrain force(); KubectlDrain ignoreDaemonSets(); ...
KubectlDrain extends KubectlCordon { @Override public V1Node execute() throws KubectlException { try { return doDrain(); } catch (ApiException | IOException ex) { throw new KubectlException(ex); } } KubectlDrain(); KubectlDrain gracePeriod(int gracePeriodSeconds); KubectlDrain force(); KubectlDrain ignoreDaemonSets(); ...
@Test public void testLoadAll() throws IOException { StringBuilder sb = new StringBuilder(); for (int i = 0; i < kinds.length; i++) { sb.append(input.replace("XXXX", kinds[i]).replace("YYYY", apiVersions[i])); sb.append("\n---\n"); } List<Object> list = null; list = (List<Object>) Yaml.loadAll(sb.toString()); for (int ...
public static List<Object> loadAll(String content) throws IOException { return loadAll(new StringReader(content)); }
Yaml { public static List<Object> loadAll(String content) throws IOException { return loadAll(new StringReader(content)); } }
Yaml { public static List<Object> loadAll(String content) throws IOException { return loadAll(new StringReader(content)); } }
Yaml { public static List<Object> loadAll(String content) throws IOException { return loadAll(new StringReader(content)); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> clazz); static...
Yaml { public static List<Object> loadAll(String content) throws IOException { return loadAll(new StringReader(content)); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> clazz); static...
@Test public void testLoadIntOrString() { try { String strInput = "targetPort: test"; String intInput = "targetPort: 1"; V1ServicePort stringPort = Yaml.loadAs(strInput, V1ServicePort.class); V1ServicePort intPort = Yaml.loadAs(intInput, V1ServicePort.class); assertFalse( "Target port for 'stringPort' was parsed to an ...
public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); }
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } }
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } }
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> claz...
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> claz...
@Test public void testLoadBytes() { try { String strInput = "data:\n hello: aGVsbG8="; V1Secret secret = Yaml.loadAs(strInput, V1Secret.class); assertEquals( "Incorrect value loaded for Base64 encoded secret", "hello", new String(secret.getData().get("hello"), UTF_8)); } catch (Exception ex) { assertNull("Unexpected ex...
public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); }
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } }
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } }
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> claz...
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> claz...
@Test public void testDateTime() { try { String strInput = "apiVersion: v1\n" + "kind: Pod\n" + "metadata:\n" + " creationTimestamp: 2018-09-06T15:12:24Z"; V1Pod pod = Yaml.loadAs(strInput, V1Pod.class); assertEquals( "Incorrect value loaded for creationTimestamp", "2018-09-06T15:12:24.000Z", new String(pod.getMetadata...
public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); }
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } }
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } }
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> claz...
Yaml { public static <T> T loadAs(String content, Class<T> clazz) { return getSnakeYaml().loadAs(new StringReader(content), clazz); } static Object load(String content); static Object load(File f); static Object load(Reader reader); static T loadAs(String content, Class<T> clazz); static T loadAs(File f, Class<T> claz...
@Test public void testTokenProvided() { final ApiClient client = new ApiClient(); new AccessTokenAuthentication("token").provide(client); assertThat(getApiKeyAuthFromClient(client).getApiKeyPrefix(), is("Bearer")); assertThat(getApiKeyAuthFromClient(client).getApiKey(), is("token")); }
@Override public void provide(ApiClient client) { client.setApiKeyPrefix("Bearer"); client.setApiKey(token); }
AccessTokenAuthentication implements Authentication { @Override public void provide(ApiClient client) { client.setApiKeyPrefix("Bearer"); client.setApiKey(token); } }
AccessTokenAuthentication implements Authentication { @Override public void provide(ApiClient client) { client.setApiKeyPrefix("Bearer"); client.setApiKey(token); } AccessTokenAuthentication(final String token); }
AccessTokenAuthentication implements Authentication { @Override public void provide(ApiClient client) { client.setApiKeyPrefix("Bearer"); client.setApiKey(token); } AccessTokenAuthentication(final String token); @Override void provide(ApiClient client); }
AccessTokenAuthentication implements Authentication { @Override public void provide(ApiClient client) { client.setApiKeyPrefix("Bearer"); client.setApiKey(token); } AccessTokenAuthentication(final String token); @Override void provide(ApiClient client); }
@Test public void testValidCertificates() throws Exception { final ApiClient client = new ApiClient(); final byte[] certificate = Files.readAllBytes(Paths.get(CLIENT_CERT_PATH)); final byte[] key = Files.readAllBytes(Paths.get(CLIENT_KEY_PATH)); new ClientCertificateAuthentication(certificate, key).provide(client); }
@Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final KeyManager[] keyManagers = SSLUtils.keyManagers(certificate...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
@Test(expected = RuntimeException.class) public void testInvalidCertificates() { final ApiClient client = new ApiClient(); new ClientCertificateAuthentication(new byte[] {}, new byte[] {}).provide(client); }
@Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final KeyManager[] keyManagers = SSLUtils.keyManagers(certificate...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
@Test public void testValidECCertificates() throws Exception { try { final ApiClient client = new ApiClient(); final byte[] certificate = Files.readAllBytes(Paths.get(CLIENT_EC_CERT_PATH)); final byte[] key = Files.readAllBytes(Paths.get(CLIENT_EC_KEY_PATH)); new ClientCertificateAuthentication(certificate, key).provid...
@Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final KeyManager[] keyManagers = SSLUtils.keyManagers(certificate...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
@Test public void testValidCertificatesChain() throws Exception { try { final ApiClient client = new ApiClient(); final byte[] certificate = Files.readAllBytes(Paths.get(CLIENT_CERT_CHAIN_PATH)); final byte[] key = Files.readAllBytes(Paths.get(CLIENT_CERT_CHAIN_KEY_PATH)); new ClientCertificateAuthentication(certificat...
@Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final KeyManager[] keyManagers = SSLUtils.keyManagers(certificate...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
@Test public void testExit1() { InputStream inputStream = new ByteArrayInputStream(OUTPUT_EXIT1.getBytes(StandardCharsets.UTF_8)); int exitCode = Exec.parseExitCode(client, inputStream); assertEquals(1, exitCode); }
static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if ...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
@Test public void testValidOldECCertificates() throws Exception { try { final ApiClient client = new ApiClient(); final byte[] certificate = Files.readAllBytes(Paths.get(CLIENT_EC_CERT_PATH)); final byte[] key = Files.readAllBytes(Paths.get(CLIENT_EC_KEY_OLD_PATH)); new ClientCertificateAuthentication(certificate, key)...
@Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final KeyManager[] keyManagers = SSLUtils.keyManagers(certificate...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
ClientCertificateAuthentication implements Authentication { @Override public void provide(ApiClient client) { String dataString = new String(key); String algo = ""; if (dataString.indexOf("BEGIN EC PRIVATE KEY") != -1) { algo = "EC"; } if (dataString.indexOf("BEGIN RSA PRIVATE KEY") != -1) { algo = "RSA"; } try { final...
@Test public void testUsernamePasswordProvided() { final ApiClient client = new ApiClient(); new UsernamePasswordAuthentication(USERNAME, PASSWORD).provide(client); assertThat(getApiKeyAuthFromClient(client).getApiKeyPrefix(), is("Basic")); assertThat( getApiKeyAuthFromClient(client).getApiKey(), is(ByteString.of(USERN...
@Override public void provide(ApiClient client) { final String usernameAndPassword = username + ":" + password; client.setApiKeyPrefix("Basic"); client.setApiKey( ByteString.of(usernameAndPassword.getBytes(StandardCharsets.ISO_8859_1)).base64()); }
UsernamePasswordAuthentication implements Authentication { @Override public void provide(ApiClient client) { final String usernameAndPassword = username + ":" + password; client.setApiKeyPrefix("Basic"); client.setApiKey( ByteString.of(usernameAndPassword.getBytes(StandardCharsets.ISO_8859_1)).base64()); } }
UsernamePasswordAuthentication implements Authentication { @Override public void provide(ApiClient client) { final String usernameAndPassword = username + ":" + password; client.setApiKeyPrefix("Basic"); client.setApiKey( ByteString.of(usernameAndPassword.getBytes(StandardCharsets.ISO_8859_1)).base64()); } UsernamePass...
UsernamePasswordAuthentication implements Authentication { @Override public void provide(ApiClient client) { final String usernameAndPassword = username + ":" + password; client.setApiKeyPrefix("Basic"); client.setApiKey( ByteString.of(usernameAndPassword.getBytes(StandardCharsets.ISO_8859_1)).base64()); } UsernamePass...
UsernamePasswordAuthentication implements Authentication { @Override public void provide(ApiClient client) { final String usernameAndPassword = username + ":" + password; client.setApiKeyPrefix("Basic"); client.setApiKey( ByteString.of(usernameAndPassword.getBytes(StandardCharsets.ISO_8859_1)).base64()); } UsernamePass...
@Test public void testAddLabels() { V1Pod pod = new V1Pod().metadata(new V1ObjectMeta()); Labels.addLabels(pod, "foo", "bar"); assertEquals(pod.getMetadata().getLabels().get("foo"), "bar"); }
public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); }
Labels { public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); } }
Labels { public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); } }
Labels { public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); } static void addLabels(KubernetesObject kubernetesObject, String label, String value)...
Labels { public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); } static void addLabels(KubernetesObject kubernetesObject, String label, String value)...
@Test public void testAddMultipleLabels() { V1Pod pod = new V1Pod().metadata(new V1ObjectMeta()); Map<String, String> newLabels = new HashMap<>(); newLabels.put("foo1", "bar1"); newLabels.put("foo2", "bar2"); Labels.addLabels(pod, newLabels); assertEquals(pod.getMetadata().getLabels().get("foo1"), "bar1"); assertEquals...
public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); }
Labels { public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); } }
Labels { public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); } }
Labels { public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); } static void addLabels(KubernetesObject kubernetesObject, String label, String value)...
Labels { public static void addLabels(KubernetesObject kubernetesObject, String label, String value) { Map<String, String> mergingLabels = new HashMap<>(); mergingLabels.put(label, value); addLabels(kubernetesObject, mergingLabels); } static void addLabels(KubernetesObject kubernetesObject, String label, String value)...
@Test public void testDefaultClientNothingPresent() { environmentVariables.set("HOME", "/non-existent"); try { ApiClient client = Config.defaultClient(); assertEquals("http: } catch (IOException ex) { fail("Unexpected exception: " + ex); } }
public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } static ApiClient fromCluster(); static ApiClient fromUrl(String url); static ApiClient fromUrl(String url, boolean validateSSL); static ApiClient fromUserPassword(String url, String user, String password); ...
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } static ApiClient fromCluster(); static ApiClient fromUrl(String url); static ApiClient fromUrl(String url, boolean validateSSL); static ApiClient fromUserPassword(String url, String user, String password); ...
@Test public void testDefaultClientHomeDir() { try { environmentVariables.set("HOME", dir.getCanonicalPath()); ApiClient client = Config.defaultClient(); assertEquals("http: } catch (Exception ex) { ex.printStackTrace(); fail("Unexpected exception: " + ex); } }
public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } static ApiClient fromCluster(); static ApiClient fromUrl(String url); static ApiClient fromUrl(String url, boolean validateSSL); static ApiClient fromUserPassword(String url, String user, String password); ...
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } static ApiClient fromCluster(); static ApiClient fromUrl(String url); static ApiClient fromUrl(String url, boolean validateSSL); static ApiClient fromUserPassword(String url, String user, String password); ...
@Test public void testDefaultClientKubeConfig() { try { environmentVariables.set("KUBECONFIG", configFile.getCanonicalPath()); ApiClient client = Config.defaultClient(); assertEquals("http: } catch (Exception ex) { ex.printStackTrace(); fail("Unexpected exception: " + ex); } }
public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } static ApiClient fromCluster(); static ApiClient fromUrl(String url); static ApiClient fromUrl(String url, boolean validateSSL); static ApiClient fromUserPassword(String url, String user, String password); ...
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } static ApiClient fromCluster(); static ApiClient fromUrl(String url); static ApiClient fromUrl(String url, boolean validateSSL); static ApiClient fromUserPassword(String url, String user, String password); ...
@Test public void testDefaultClientPrecedence() { try { environmentVariables.set("HOME", dir.getCanonicalPath()); environmentVariables.set("KUBECONFIG", configFile.getCanonicalPath()); ApiClient client = Config.defaultClient(); assertEquals("http: } catch (Exception ex) { ex.printStackTrace(); fail("Unexpected exceptio...
public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } }
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } static ApiClient fromCluster(); static ApiClient fromUrl(String url); static ApiClient fromUrl(String url, boolean validateSSL); static ApiClient fromUserPassword(String url, String user, String password); ...
Config { public static ApiClient defaultClient() throws IOException { return ClientBuilder.standard().build(); } static ApiClient fromCluster(); static ApiClient fromUrl(String url); static ApiClient fromUrl(String url, boolean validateSSL); static ApiClient fromUserPassword(String url, String user, String password); ...
@Test public void testWatchEnd() throws IOException { JSON json = new JSON(); Watch<V1ConfigMap> watch = new Watch<V1ConfigMap>( json, null, new TypeToken<Watch.Response<V1ConfigMap>>() {}.getType(), null); JsonObject metadata = new JsonObject(); metadata.addProperty("name", "foo"); metadata.addProperty("namespace", "b...
protected Response<T> parseLine(String line) throws IOException { if (!isStatus(line)) { return json.deserialize(line, watchType); } Type statusType = new TypeToken<Response<V1Status>>() {}.getType(); Response<V1Status> status = json.deserialize(line, statusType); return new Response<T>(status.type, status.object); }
Watch implements Watchable<T>, Closeable { protected Response<T> parseLine(String line) throws IOException { if (!isStatus(line)) { return json.deserialize(line, watchType); } Type statusType = new TypeToken<Response<V1Status>>() {}.getType(); Response<V1Status> status = json.deserialize(line, statusType); return new R...
Watch implements Watchable<T>, Closeable { protected Response<T> parseLine(String line) throws IOException { if (!isStatus(line)) { return json.deserialize(line, watchType); } Type statusType = new TypeToken<Response<V1Status>>() {}.getType(); Response<V1Status> status = json.deserialize(line, statusType); return new R...
Watch implements Watchable<T>, Closeable { protected Response<T> parseLine(String line) throws IOException { if (!isStatus(line)) { return json.deserialize(line, watchType); } Type statusType = new TypeToken<Response<V1Status>>() {}.getType(); Response<V1Status> status = json.deserialize(line, statusType); return new R...
Watch implements Watchable<T>, Closeable { protected Response<T> parseLine(String line) throws IOException { if (!isStatus(line)) { return json.deserialize(line, watchType); } Type statusType = new TypeToken<Response<V1Status>>() {}.getType(); Response<V1Status> status = json.deserialize(line, statusType); return new R...
@Test public void deleteNamespacedJobReturningStatus() { V1Status status = new V1Status().kind("Status").code(200).message("good!"); stubFor( delete(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")) .willReturn(aResponse().withStatus(200).withBody(new Gson().toJson(status)))); KubernetesApiResponse<V1Job> dele...
public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKuberne...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKuberne...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKuberne...
@Test public void testExit126() { InputStream inputStream = new ByteArrayInputStream(OUTPUT_EXIT126.getBytes(StandardCharsets.UTF_8)); int exitCode = Exec.parseExitCode(client, inputStream); assertEquals(126, exitCode); }
static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnType); if ...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
Exec { static int parseExitCode(ApiClient client, InputStream inputStream) { try { Type returnType = new TypeToken<V1Status>() {}.getType(); String body; try (final Reader reader = new InputStreamReader(inputStream)) { body = CharStreams.toString(reader); } V1Status status = client.getJSON().deserialize(body, returnTyp...
@Test public void deleteNamespacedJobReturningDeletedObject() { V1Job foo1 = new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1")); stubFor( delete(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")) .willReturn(aResponse().withStatus(200).withBody(new Gson().toJson(foo1)))); Kub...
public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKuberne...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKuberne...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKuberne...
@Test public void deleteNamespacedJobReturningForbiddenStatus() { V1Status status = new V1Status().kind("Status").code(403).message("good!"); stubFor( delete(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")) .willReturn(aResponse().withStatus(403).withBody(new Gson().toJson(status)))); KubernetesApiResponse<V1...
public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKuberne...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKuberne...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> delete(String name) { return delete(name, new DeleteOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKuberne...
@Test public void createNamespacedJobReturningObject() { V1Job foo1 = new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1")); stubFor( post(urlEqualTo("/apis/batch/v1/namespaces/default/jobs")) .willReturn(aResponse().withStatus(200).withBody(new Gson().toJson(foo1)))); KubernetesApiResp...
public KubernetesApiResponse<ApiType> create(ApiType object) { return create(object, new CreateOptions()); }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> create(ApiType object) { return create(object, new CreateOptions()); } }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> create(ApiType object) { return create(object, new CreateOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKu...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> create(ApiType object) { return create(object, new CreateOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKu...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> create(ApiType object) { return create(object, new CreateOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKu...
@Test public void updateNamespacedJobReturningObject() { V1Job foo1 = new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1")); stubFor( put(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")) .willReturn(aResponse().withStatus(200).withBody(new Gson().toJson(foo1)))); KubernetesApi...
public KubernetesApiResponse<ApiType> update(ApiType object) { return update(object, new UpdateOptions()); }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> update(ApiType object) { return update(object, new UpdateOptions()); } }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> update(ApiType object) { return update(object, new UpdateOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKu...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> update(ApiType object) { return update(object, new UpdateOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKu...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> update(ApiType object) { return update(object, new UpdateOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKu...
@Test public void patchNamespacedJobReturningObject() { V1Patch v1Patch = new V1Patch("{}"); V1Job foo1 = new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1")); stubFor( patch(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1")) .withHeader("Content-Type", containing(V1Patch.PATCH...
public KubernetesApiResponse<ApiType> patch(String name, String patchType, V1Patch patch) { return patch(name, patchType, patch, new PatchOptions()); }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> patch(String name, String patchType, V1Patch patch) { return patch(name, patchType, patch, new PatchOptions()); } }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> patch(String name, String patchType, V1Patch patch) { return patch(name, patchType, patch, new PatchOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersio...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> patch(String name, String patchType, V1Patch patch) { return patch(name, patchType, patch, new PatchOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersio...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> patch(String name, String patchType, V1Patch patch) { return patch(name, patchType, patch, new PatchOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersio...
@Test public void testReadTimeoutShouldThrowException() { ApiClient apiClient = new ClientBuilder().setBasePath("http: apiClient.setHttpClient( apiClient .getHttpClient() .newBuilder() .readTimeout(1, TimeUnit.MILLISECONDS) .build()); stubFor( get(urlEqualTo("/apis/batch/v1/namespaces/foo/jobs/test")) .willReturn(aResp...
public KubernetesApiResponse<ApiType> get(String name) { return get(name, new GetOptions()); }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> get(String name) { return get(name, new GetOptions()); } }
GenericKubernetesApi { public KubernetesApiResponse<ApiType> get(String name) { return get(name, new GetOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKubernetesApi( ...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> get(String name) { return get(name, new GetOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKubernetesApi( ...
GenericKubernetesApi { public KubernetesApiResponse<ApiType> get(String name) { return get(name, new GetOptions()); } GenericKubernetesApi( Class<ApiType> apiTypeClass, Class<ApiListType> apiListTypeClass, String apiGroup, String apiVersion, String resourcePlural); GenericKubernetesApi( ...
@Test public void testPersistence() throws IOException { File file = folder.newFile("testconfig"); FilePersister fp = new FilePersister(file.getPath()); KubeConfig config = KubeConfig.loadKubeConfig(new FileReader(KUBECONFIG_FILE_PATH)); fp.save( config.getContexts(), config.getClusters(), config.getUsers(), config.get...
public void save( ArrayList<Object> contexts, ArrayList<Object> clusters, ArrayList<Object> users, Object preferences, String currentContext) throws IOException { HashMap<String, Object> config = new HashMap<>(); config.put("apiVersion", "v1"); config.put("kind", "Config"); config.put("current-context", currentContext)...
FilePersister implements ConfigPersister { public void save( ArrayList<Object> contexts, ArrayList<Object> clusters, ArrayList<Object> users, Object preferences, String currentContext) throws IOException { HashMap<String, Object> config = new HashMap<>(); config.put("apiVersion", "v1"); config.put("kind", "Config"); co...
FilePersister implements ConfigPersister { public void save( ArrayList<Object> contexts, ArrayList<Object> clusters, ArrayList<Object> users, Object preferences, String currentContext) throws IOException { HashMap<String, Object> config = new HashMap<>(); config.put("apiVersion", "v1"); config.put("kind", "Config"); co...
FilePersister implements ConfigPersister { public void save( ArrayList<Object> contexts, ArrayList<Object> clusters, ArrayList<Object> users, Object preferences, String currentContext) throws IOException { HashMap<String, Object> config = new HashMap<>(); config.put("apiVersion", "v1"); config.put("kind", "Config"); co...
FilePersister implements ConfigPersister { public void save( ArrayList<Object> contexts, ArrayList<Object> clusters, ArrayList<Object> users, Object preferences, String currentContext) throws IOException { HashMap<String, Object> config = new HashMap<>(); config.put("apiVersion", "v1"); config.put("kind", "Config"); co...