src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
HumidityNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { int relativeHumidity = decodeHumidity(bytes[0]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of("relative_humidity", relativeHumidity)); processor.onNext(sensorLog); } HumidityNotification(Sens...
@Test public void producesValidSensorLog() { Faker faker = new Faker(); int humidity = faker.number().numberBetween(0, 100); SensorConfig config = new SensorConfig("someId", "", null); ReplayProcessor<SensorLog> processor = ReplayProcessor.create(10); HumidityNotification notification = new HumidityNotification(config,...
PressureNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { float pressure = decodePressure(bytes); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of(PRESSURE_VALUE_ID, pressure)); processor.onNext(sensorLog); } PressureNotification(SensorConfig config, Fl...
@Test public void producesValidSensorLog() { Faker faker = new Faker(); int pressure = faker.number().numberBetween(-100000, 100000); float decimal = (float)faker.number().randomDouble(4, 0, 1); byte[] pressureBytes = Ints.toByteArray(pressure); SensorConfig config = new SensorConfig("someId", "thingy",null); ReplayPro...
AirQualityNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { int eCO2 = decodeECO2(bytes[1], bytes[0]); int tvoc = decodeTVOC(bytes[3], bytes[2]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of(CO2_VALUE_ID, eCO2, TVOC_VALUE_ID, tvoc)); processor.onNex...
@Test public void producesValidSensorLog() { int eCO2 = 400; byte[] eCO2bytes = Ints.toByteArray(eCO2); int TVOC = 121; byte[] TVOCbytes = Ints.toByteArray(TVOC); SensorConfig config = new SensorConfig("someId", "sensortag", null); ReplayProcessor<SensorLog> processor = ReplayProcessor.create(10); AirQualityNotificatio...
WebSensorTask extends TimerTask { public List<String[]> pollSensor() { setDatesPollInterval(); List<String[]> data = null; Call<List<String[]>> call = webApi.getHcJsonData(getQueryParameters()); try { data = call.execute().body(); for (String[] dataArray: data) { log.info("Time: " + dataArray[0] + " Data: " + dataArray...
@Test public void testSensorTask() throws IOException { SensorConfig webSensorConfig1 = new SensorConfig("web", ImmutableMap.of( WebSensor.CONFIG_KEY_FAMILY, "wasp", WebSensor.CONFIG_KEY_SENSOR, "ES_B_05_416_7C15", WebSensor.CONFIG_KEY_SUB_SENSOR, "BAT" )); MockWebServer server = new MockWebServer(); server.enqueue(new...
OpticalNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { float lux = decodeLux(bytes[1], bytes[0]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of(LIGHT_INTENSITY_VALUE_ID, lux)); processor.onNext(sensorLog); } OpticalNotification(SensorConfig config,...
@Test public void producesValidSensorLog() { Faker faker = new Faker(); int mantissa = faker.number().numberBetween(0, 4096); int exponent = faker.number().numberBetween(0, 16); float lux = mantissa * (float)Math.pow(2, exponent) / 100.0f; SensorConfig config = new SensorConfig("someId", "thingy", null); ReplayProcesso...
TemperatureNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { float objectTemp = decodeTemperature(bytes[1], bytes[0]); float ambientTemp = decodeTemperature(bytes[3], bytes[2]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of(OBJECT_TEMP_VALUE_ID, obje...
@Test public void producesValidSensorLog() { Faker faker = new Faker(); int objectTemp = faker.number().numberBetween(-50, 50); float objectTempDecimal = (float)faker.number().randomDouble(4, 0, 1); int ambientTemp = faker.number().numberBetween(-50, 50); float ambientTempDecimal = (float)faker.number().randomDouble(4,...
HumidityNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { float temperature = decodeTemperature(bytes[1], bytes[0]); float humidity = decodeHumidity(bytes[3], bytes[2]); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of(HUMIDITY_VALUE_ID, humidity, TEMPE...
@Test public void producesValidSensorLog() { Faker faker = new Faker(); double humidity = faker.number().randomDouble(4, 0, 50); int humidityNorm = (int)(humidity * 65536 / 100); double temperature = faker.number().randomDouble(4, -50, 50); int temperatureNorm = (int)((temperature + 40) / 165 * 65536); SensorConfig con...
PressureNotification implements BluetoothNotification<byte[]> { @Override public void run(byte[] bytes) { float pressure = decodePressure(new byte[]{0x00, bytes[5], bytes[4], bytes[3]}); SensorLog sensorLog = new SensorLog(config.getId(), ImmutableMap.of("pressure", pressure)); processor.onNext(sensorLog); } PressureNo...
@Test public void producesValidSensorLog() { Faker faker = new Faker(); double pressure = faker.number().randomDouble(2, 0, 5000); int pressureNorm = (int)(pressure * 100); SensorConfig config = new SensorConfig("someId", "sensortag",null); ReplayProcessor<SensorLog> processor = ReplayProcessor.create(10); PressureNoti...
ExtensionLoaderFactory { public static <T> T load(final Class<T> service) { return ExtensionLoader.getExtensionLoader(service).load(findClassLoader()); } static T load(final Class<T> service); static T load(final Class<T> service, final String name); static T load(final Class<T> service, final ClassLoader loader); sta...
@Test public void testSPI() { HmilyTestSPI hmilyTestSPI = ExtensionLoaderFactory.load(HmilyTestSPI.class); assertThat(hmilyTestSPI.getClass().getName(), is(NoHelloTestSPI.class.getName())); HmilyTestSPI test2 = ExtensionLoaderFactory.load(HmilyTestSPI.class); assertThat(test2.getClass().getName(), is(NoHelloTestSPI.cla...
ApolloConfigLoader implements ConfigLoader<ApolloConfig> { private void apolloLoad(final Supplier<Context> context, final LoaderHandler<ApolloConfig> handler, final ApolloConfig config) { if (config != null) { check(config); LOGGER.info("loader apollo config: {}", config); String fileExtension = config.getFileExtension...
@Test public void testApolloLoad() { ConfigScan.scan(); ServerConfigLoader loader = new ServerConfigLoader(); ApolloConfigLoader apolloConfigLoader = new ApolloConfigLoader(client); loader.load(ConfigLoader.Context::new, (context, config) -> { if (config != null) { if (StringUtils.isNoneBlank(config.getConfigMode())) {...
NacosConfigLoader implements ConfigLoader<NacosConfig> { private void nacosLoad(final Supplier<Context> context, final LoaderHandler<NacosConfig> handler, final NacosConfig config) { if (config != null) { check(config); LOGGER.info("loader nacos config: {}", config); String fileExtension = config.getFileExtension(); Pr...
@Test public void testNacosLoad() { ConfigScan.scan(); ServerConfigLoader loader = new ServerConfigLoader(); NacosConfigLoader nacosConfigLoader = new NacosConfigLoader(client); loader.load(ConfigLoader.Context::new, (context, config) -> { if (config != null) { if (StringUtils.isNoneBlank(config.getConfigMode())) { Str...
LocalConfigLoader implements ConfigLoader<Config> { @Override public void load(final Supplier<Context> context, final LoaderHandler<Config> handler) { ConfigLoader<Config> original = context.get().getOriginal(); original.load(context, handler); } @Override void load(final Supplier<Context> context, final LoaderHandler...
@Test public void load() { ConfigScan.scan(); ServerConfigLoader loader = new ServerConfigLoader(); loader.load(ConfigLoader.Context::new, (context, config) -> { System.out.println("config:---->" + config); if (config != null) { if (StringUtils.isNotBlank(config.getConfigMode())) { String configMode = config.getConfigM...
ZookeeperConfigLoader implements ConfigLoader<ZookeeperConfig> { @Override public void load(final Supplier<Context> context, final LoaderHandler<ZookeeperConfig> handler) { LoaderHandler<ZookeeperConfig> zookeeperLoad = (c, config) -> zookeeperLoad(c, handler, config); againLoad(context, zookeeperLoad, ZookeeperConfig....
@Test @Ignore public void realZookeeperLoad() { ZookeeperConfig remoteConfig = new ZookeeperConfig(); remoteConfig.setServerList("127.0.0.1:2181"); CuratorZookeeperClient client = CuratorZookeeperClient.getInstance(remoteConfig); client.persist("/hmily/xiaoyu", FileUtils.readYAML("hmily-zookeeper.yml")); ConfigScan.sca...
ZookeeperConfigLoader implements ConfigLoader<ZookeeperConfig> { private void zookeeperLoad(final Supplier<Context> context, final LoaderHandler<ZookeeperConfig> handler, final ZookeeperConfig config) { if (config != null) { check(config); if (Objects.isNull(client)) { client = CuratorZookeeperClient.getInstance(config...
@Test public void testZookeeperLoad() { ConfigScan.scan(); ServerConfigLoader loader = new ServerConfigLoader(); loader.load(ConfigLoader.Context::new, (context, config) -> { System.out.println("config:---->" + config); if (config != null) { if (StringUtils.isNotBlank(config.getConfigMode())) { String configMode = conf...
StringUtils { public static boolean isNoneBlank(final CharSequence... css) { return !isAnyBlank(css); } static boolean isNoneBlank(final CharSequence... css); static boolean isEmpty(final Object[] array); static boolean isBlank(final CharSequence cs); }
@Test public void testIsNoneBlank() { Assert.assertFalse(StringUtils.isNoneBlank((CharSequence) null)); Assert.assertFalse(StringUtils.isNoneBlank("")); Assert.assertFalse(StringUtils.isNoneBlank("", "", "")); Assert.assertTrue(StringUtils.isNoneBlank("a", "b", "c")); }
StringUtils { public static boolean isEmpty(final Object[] array) { return array == null || array.length == 0; } static boolean isNoneBlank(final CharSequence... css); static boolean isEmpty(final Object[] array); static boolean isBlank(final CharSequence cs); }
@Test public void testIsEmpty() { Assert.assertTrue(true); Assert.assertTrue(StringUtils.isEmpty(new String[0])); Assert.assertFalse(StringUtils.isEmpty(new String[]{"a", "b", "c"})); }
StringUtils { public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; } static boolean isNoneBlank(final CharSequence... css); static...
@Test public void testIsBlank() { Assert.assertTrue(StringUtils.isBlank(null)); Assert.assertTrue(StringUtils.isBlank("")); Assert.assertTrue(StringUtils.isBlank(" ")); Assert.assertFalse(StringUtils.isBlank("foobar")); Assert.assertFalse(StringUtils.isBlank("foo bar")); }
EtcdConfigLoader implements ConfigLoader<EtcdConfig> { private void etcdLoad(final Supplier<Context> context, final LoaderHandler<EtcdConfig> handler, final EtcdConfig config) { if (config != null) { check(config); LOGGER.info("loader etcd config: {}", config); String fileExtension = config.getFileExtension(); Property...
@Test public void testEtcdLoad() { ConfigScan.scan(); ServerConfigLoader loader = new ServerConfigLoader(); EtcdConfigLoader etcdConfigLoader = new EtcdConfigLoader(client); loader.load(ConfigLoader.Context::new, (context, config) -> { if (config != null) { if (StringUtils.isNoneBlank(config.getConfigMode())) { String ...
JavaBeanBinder extends BeanBinder { @Override public <T> T bind(final PropertyName name, final BindData<T> target, final Binder.Env env, final PropertyBinder propertyBinder) { boolean hasKnownBindableProperties = env.getSource().containsDescendantOf(name); Bean<T> bean = Bean.get(target, hasKnownBindableProperties); if...
@Test public void testJavaBeanBind() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.stringTest", "123"); map.put("hmily.integerTest", 456); map.put("hmily.doubleTest", 42.12); map.put("hmily.longTest", 100L); map.put("hmily.chartTest", 'a'); map.put("hmily.floatTest", 12.1F); map...
MapBinder extends AggregateBinder<Map<Object, Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { Map<Object, Object> map = new HashMap<>(16); boolean hasDescendants = env.getSource().containsDescendantOf(...
@Test public void testMap() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.map.userName", "sixh"); map.put("hmily.map.passWord", 123456); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigProper...
CollectionBinder extends IndexedBinder<Collection<Object>> { @Override public Object bind(final PropertyName propertyName, final BindData<?> target, final Binder.Env env, final AggregateElementBinder elementBinder) { DataType type = target.getType(); Class<?> collectionType = target.getValue() != null ? List.class : ty...
@Test public void testArrayList() { String name = "hmily.yml"; Map<String, Object> map = new HashMap<>(); map.put("hmily.list[0]", 123); map.put("hmily.list[1]", 234); PropertyKeySource<?> propertySource = new MapPropertyKeySource(name, map); ConfigPropertySource configPropertySource = new DefaultConfigPropertySource<>...
MathUtil { public static boolean isOdd(int number) { return number % 2 == 1; } static boolean isOdd(int number); }
@Test public void testOdd() { assertTrue(MathUtil.isOdd(3)); assertFalse(MathUtil.isOdd(4)); }
LRMSPopulateWorkload { static void computeTrueAnswers(Configuration conf, Workload workload) throws Exception { long T0 = conf.getTstart(), T1 = conf.getTend(); ArrayList<LongRange> intervals = new ArrayList<>(); ArrayList<Query> queries = new ArrayList<>(); for (List<Query> classQueries: workload.values()) { for (Quer...
@Test public void computeTrueAnswers() throws Exception { File configFile = File.createTempFile("test-workload", "toml"); configFile.deleteOnExit(); try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(configFile.getAbsolutePath()))) { writer.write("directory = \"/tmp\"\n" + "[data]\n" + "tstart = 0\n" + "ten...
GenericWindowing implements Windowing { @Override public long getFirstContainingTime(long Tl, long Tr, long T) { assert 0 <= Tl && Tl <= Tr && Tr < T; long l = T-1 - Tr, r = T-1 - Tl, length = Tr - Tl + 1; if (!addWindowsUntilLength(length)) { return -1; } long firstMarker = firstWindowOfLength.ceilingEntry(length).get...
@Test public void getFirstContainingTime() throws Exception { GenericWindowing exp = new GenericWindowing(new ExponentialWindowLengths(2)); assertEquals(101, exp.getFirstContainingTime(98, 99, 100)); assertEquals(103, exp.getFirstContainingTime(96, 99, 100)); assertEquals(107, exp.getFirstContainingTime(92, 99, 100)); ...
GenericWindowing implements Windowing { @Override public long getSizeOfFirstWindow() { return firstWindowLength; } GenericWindowing(WindowLengthsSequence windowLengths); @Override long getFirstContainingTime(long Tl, long Tr, long T); @Override long getSizeOfFirstWindow(); @Override List<Long> getWindowsCoveringUpto(lo...
@Test public void getSizeOfFirstWindow() throws Exception { GenericWindowing exp = new GenericWindowing(new ExponentialWindowLengths(2)); assertEquals(1, exp.getSizeOfFirstWindow(), 1); final long S = 2492; GenericWindowing rp = new GenericWindowing(new WindowLengthsSequence() { private long i = 1; @Override public lon...
GenericWindowing implements Windowing { @Override public List<Long> getWindowsCoveringUpto(long N) { if (N <= 0) return Collections.emptyList(); addWindowsPastMarker(N); List<Long> ret = new ArrayList<>(); long prevMarker = 0; for (long currMarker: windowStartMarkers) { if (currMarker == 0) continue; if (currMarker <= ...
@Test public void getWindowsCoveringUpto() throws Exception { GenericWindowing exp = new GenericWindowing(new ExponentialWindowLengths(2)); assertThat(exp.getWindowsCoveringUpto(62), is(Arrays.asList(1L, 2L, 4L, 8L, 16L))); assertThat(exp.getWindowsCoveringUpto(63), is(Arrays.asList(1L, 2L, 4L, 8L, 16L, 32L))); }
WorldLoader { @Nullable public static World worldFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { if (useUUID) { UUID worldUUID; try { worldUUID = UUID.fromString(conf.getString(WORLD_UID, "")); } catch (IllegalArgumentException e) { return null; } return Bukkit.getWorld(worldUUID); } else { String wor...
@Test public void worldFromConfValidName() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.WORLD_NAME, "test"); when(Bukkit.getWorld("test")).thenReturn(mock(World.class)); World w = WorldLoader.worldFromConfig(conf, false); Assert.assertNotNull(w); } @Test public void worldFromConfValidUUID() ...
WorldLoader { @Nullable public static Location blockLocationFromConfig(@NotNull ConfigurationSection conf, boolean useUUID) { World world = worldFromConfig(conf, useUUID); if (world == null) { return null; } Location loc = worldlessBlockLocationFromConfig(conf); if (loc == null) { return null; } loc.setWorld(world); re...
@Test public void blockLocationFromConfigValid() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.X, 6); conf.set(WorldLoader.Y, 0); conf.set(WorldLoader.Z, -4); conf.set(WorldLoader.WORLD_NAME, "test"); when(Bukkit.getWorld("test")).thenReturn(mock(World.class)); Location loc = WorldLoader.bloc...
FileUtils { @NotNull public static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) throws IOException { File file = getDatafolderFile(plugin, children); createFileSafely(file); return file; } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFil...
@Test public void createDataFolderCreatesCorrectPath() throws IOException { File file = FileUtils.createDatafolderFile(plugin, "test.json"); assertTrue(file.exists()); assertTrue(file.isFile()); assertEquals(dataFolder.getRoot().getPath() + File.separator + "test.json", file.getPath()); } @Test public void createDataFo...
FileUtils { public static boolean write(@NotNull String string, @NotNull Plugin plugin, @NotNull String... path) throws IOException { return write(string, createDatafolderFile(plugin, path)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @No...
@Test public void writeFailsWhenGivenFileIsFolder() throws IOException { assertFalse(FileUtils.write("whatever", plugin)); }
FileUtils { @NotNull public static File getDatafolderFile(@NotNull Plugin plugin, @NotNull String... children) { try { return Paths.get(plugin.getDataFolder().getAbsolutePath(), children).toFile(); } catch (NullPointerException e) { throw new IllegalArgumentException( "One of the children given is null. children: " + j...
@Test public void getDatafolderFileDoesNotCreateAnything() { File file = FileUtils.getDatafolderFile(plugin, "notafile.txt"); assertFalse(file.exists()); } @Test(expected = IllegalArgumentException.class) public void getDatafolderFileWithNullElementReturnsNull() { FileUtils.getDatafolderFile(plugin, null, "notafile.txt...
FileUtils { @Nullable public static List<File> getFiles(@NotNull Plugin plugin, @NotNull String... subPath) { return getFiles(getDatafolderFile(plugin, subPath)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); st...
@Test public void getFilesReturnAllFilesInFolder() throws IOException { Random random = new Random(); int nrOfFiles = random.nextInt(5) + 10; List<File> createdFiles = new ArrayList<>(); for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "file" + i); createdFiles.add(file); assertTrue(fi...
FileUtils { @Nullable public static List<String> getFileNames(@NotNull Plugin plugin, @NotNull String... subPath) { List<File> files = getFiles(plugin, subPath); if (files == null) { return null; } return getFileNames(files); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafold...
@Test public void getFileNamesIgnoresFolders() throws IOException { Random random = new Random(); int nrOfFiles = random.nextInt(5) + 40; List<String> createdFiles = new ArrayList<>(); for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "file" + i); if (random.nextBoolean()) { createdFile...
FileUtils { @NotNull public static List<File> getRecursiveFiles(boolean excludeHyphenPrefix, @NotNull Plugin plugin, @NotNull String... children) { return getRecursiveFiles(excludeHyphenPrefix, getDatafolderFile(plugin, children)); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDa...
@Test public void getRecursiveFilesIsSameAsGetFilesWhenNoSubfolders() throws IOException { Random random = new Random(); int nrOfFiles = random.nextInt(5) + 40; List<File> createdFiles = new ArrayList<>(); for (int i = 0; i < nrOfFiles; i++) { File file = new File(plugin.getDataFolder(), "recfile" + i); createdFiles.ad...
FileUtils { @Nullable public static InputStream getInternalFileStream(@NotNull String... absPath) { return getInternalFileStream(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static vo...
@Test public void getInternalFileStreamBinFileEquals() throws IOException { String s = "/" + String.join("/", TEST_BIN_FILE_WITH_DIR_PATH); InputStream isE = FileUtilsTest.class.getResourceAsStream(s); assertNotNull(isE); InputStream isA = FileUtils.getInternalFileStream(TEST_BIN_FILE_WITH_DIR_PATH); assertNotNull(isA)...
FileUtils { @Nullable public static String readInternalFile(@NotNull String... absPath) { return readInternalFile(FileUtils.class, absPath); } static boolean createParentFolders(@NotNull File file); @NotNull static File createDatafolderFile(@NotNull Plugin plugin, @NotNull String... children); static void createFileSa...
@Test public void readInternalFileReadsTestFileCorrectly() throws IOException { String s = "/" + String.join("/", TEST_FILE_WITH_DIR_PATH); InputStream is = FileUtilsTest.class.getResourceAsStream(s); assertNotNull(is); String fileContent = IOUtils.toString(is); assertEquals(fileContent, FileUtils.readInternalFile(TEST...
InventoryUtil { public static int count(@NotNull Inventory inv, @NotNull ItemStack item) { int amount = 0; for (ItemStack invItem : inv.getContents()) { if (item.isSimilar(invItem)) { amount += invItem.getAmount(); } } return amount; } @SuppressWarnings("deprecation") static void removeInvItem(@NotNull final Inventory...
@Test public void testCountOneEqualElement() { int amount = 16; ItemStack item = new ItemStack(Material.APPLE, amount); Inventory inv = mock(Inventory.class); when(inv.getContents()).thenReturn(new ItemStack[] {item}); Assert.assertEquals(amount, InventoryUtil.count(inv, item)); } @Test public void testCountNoItems() {...
ConfigUtil { public static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources) throws IOException { saveDefaultResources(plugin, true, resources); } static void saveDefaultResources(@NotNull Plugin plugin, @NotNull String... resources); static void saveDefaultResources(@NotNull Plugin plugi...
@Test(expected = FileNotFoundException.class) public void saveDefaultResourcesNotExistingWhenNotCreating() throws IOException { ConfigUtil.saveDefaultResources(plugin, false, NON_EXISTING_TEST_FILE_WITH_DIR_PATH); } @Test public void saveDefaultResourcesDoesNotOverwrite() throws IOException { String content = "yaegstfi...
WorldLoader { @Nullable public static Location worldlessBlockLocationFromConfig(@NotNull ConfigurationSection conf) { try { int x = Integer.parseInt(conf.getString(X)); int y = Integer.parseInt(conf.getString(Y)); int z = Integer.parseInt(conf.getString(Z)); return new Location(null, x, y, z); } catch (NumberFormatExce...
@Test public void worldlessBlockLocFromConfEmpty() { Location loc = WorldLoader.worldlessBlockLocationFromConfig(new YamlConfiguration()); Assert.assertNull(loc); } @Test public void worldlessBlockLocFromConfValid() { YamlConfiguration conf = new YamlConfiguration(); conf.set(WorldLoader.X, 4); conf.set(WorldLoader.Y, ...
MainPresenter extends BaseTypedPresenter<String, Throwable> { @Override public void onViewResumed() { getView().showData("This is some awesome data"); getView().showError(new RuntimeException("Exceptional Error")); } MainPresenter(ITypedView<String, Throwable> view); @Override void onViewResumed(); }
@Test public void testShowDataOnResume() { mPresenter.onViewResumed(); verify(mView).showData(anyString()); } @Test public void testShowErrorOnResume() { mPresenter.onViewResumed(); verify(mView).showError(any(Throwable.class)); }
EclipseCollectionsDeckOfCardsAsList { public ImmutableList<Card> getCards() { return this.cards; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerH...
@Test public void allCards() { Assert.assertEquals(this.jdkDeck.getCards(), this.ecDeck.getCards()); } @Test public void cardsAreImmutable() { var ecCards = this.ecDeck.getCards().castToList(); Verify.assertThrows( UnsupportedOperationException.class, () -> ecCards.remove(0)); Verify.assertThrows( UnsupportedOperationE...
HashBag implements MutableBag<T> { public void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer) { Counter index = new Counter(); this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { biConsumer.accept(key, index.getCount()); index.increment(); } }); } @Override int sizeDistinct(); @Ove...
@Test public void forEachWithIndex() { MutableList<String> list = MutableList.empty(); this.testObj.withAll("1", "2", "3", "2", "3", "3") .forEachWithIndex((each, index) -> list.add(each + index)); Assert.assertEquals(MutableList.of("10", "21", "22", "33", "34", "35"), list); }
HashBag implements MutableBag<T> { @Override public boolean add(T element) { this.backingMap.merge(element, 1, (existingValue, newValue) -> existingValue + 1); this.size++; return true; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Ob...
@Test public void add() { this.testObj.add("1"); this.testObj.add("2"); this.testObj.add("2"); Assert.assertEquals(MutableBag.of("1", "2", "2"), this.testObj); }
HashBag implements MutableBag<T> { @Override public boolean remove(Object o) { return this.removeOccurrences((T) o, Integer.MAX_VALUE); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer...
@Test public void remove() { this.testObj.add("1"); this.testObj.add("2"); this.testObj.add("2"); Assert.assertEquals(MutableBag.of("1", "2", "2"), this.testObj); this.testObj.remove("2"); Assert.assertEquals(MutableBag.of("1"), this.testObj); this.testObj.remove("1"); Assert.assertEquals(MutableBag.empty(), this.testO...
HashBag implements MutableBag<T> { @Override public boolean containsAll(Collection<?> c) { return c.stream().allMatch(each -> this.backingMap.containsKey(each)); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void f...
@Test public void containsAll() { Assert.assertTrue(this.testObj.containsAll(MutableList.empty())); Assert.assertFalse(this.testObj.containsAll(MutableList.of("1"))); this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertTrue(this.testObj.containsAll(MutableList.of("1"))); Assert.assertTrue(this.testObj.cont...
HashBag implements MutableBag<T> { @Override public boolean addAll(Collection<? extends T> c) { int sizeBefore = this.size; c.forEach(each -> this.addOccurrence(each)); return sizeBefore != this.size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o...
@Test public void addAll() { Assert.assertFalse(this.testObj.addAll(MutableList.empty())); Assert.assertEquals(MutableBag.empty(), this.testObj); Assert.assertTrue(this.testObj.addAll(MutableList.of("1", "2", "2"))); Assert.assertEquals(MutableBag.of("1", "2", "2"), this.testObj); }
HashBag implements MutableBag<T> { @Override public boolean removeAll(Collection<?> c) { int sizeBefore = this.size; c.forEach(each -> this.removeOccurrences((T) each, Integer.MAX_VALUE)); return sizeBefore != this.size; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boole...
@Test public void removeAll() { Assert.assertFalse(this.testObj.removeAll(MutableList.empty())); this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertTrue(this.testObj.removeAll(MutableList.of("1", "2"))); Assert.assertEquals(MutableBag.of("3", "3", "3"), this.testObj); Assert.assertFalse(this.testObj.remov...
HashBag implements MutableBag<T> { @Override public void clear() { this.backingMap.clear(); this.size = 0; } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsum...
@Test public void clear() { this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertFalse(this.testObj.isEmpty()); this.testObj.clear(); Assert.assertTrue(this.testObj.isEmpty()); Assert.assertEquals(0, this.testObj.size()); Assert.assertEquals(0, this.testObj.sizeDistinct()); }
HashBag implements MutableBag<T> { @Override public int getOccurrences(T element) { return this.backingMap.getOrDefault(element, 0); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? ...
@Test public void getOccurrences() { this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertEquals(1, this.testObj.getOccurrences("1")); Assert.assertEquals(2, this.testObj.getOccurrences("2")); Assert.assertEquals(3, this.testObj.getOccurrences("3")); Assert.assertEquals(0, this.testObj.getOccurrences("4"));...
HashBag implements MutableBag<T> { @Override public Iterator<T> iterator() { return new BagIterator(); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super T, Integer> biConsumer);...
@Test public void iterator() { this.testObj.withAll("1", "2", "3", "2", "3", "3"); Iterator<String> iterator = this.testObj.iterator(); Assert.assertEquals("1", iterator.next()); Assert.assertTrue(iterator.hasNext()); iterator.remove(); Assert.assertEquals("2", iterator.next()); iterator.remove(); Assert.assertEquals("...
HashBag implements MutableBag<T> { @Override public boolean addOccurrence(T element) { return this.addOccurrences(element, 1); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? super ...
@Test public void addOccurrence() { this.testObj.addOccurrence("1"); Assert.assertEquals(MutableBag.of("1"), this.testObj); Assert.assertEquals(1, this.testObj.size()); Assert.assertEquals(1, this.testObj.sizeDistinct()); }
EclipseCollectionsDeckOfCardsAsList { public ImmutableListMultimap<Suit, Card> getCardsBySuit() { return this.cardsBySuit; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random...
@Test public void cardsBySuitIsImmutable() { var ecCardsBySuit = this.ecDeck.getCardsBySuit(); Verify.assertThrows( UnsupportedOperationException.class, () -> ecCardsBySuit.get(Suit.CLUBS).castToList().remove(0)); Verify.assertThrows( UnsupportedOperationException.class, () -> ecCardsBySuit.get(Suit.CLUBS).castToList()...
HashBag implements MutableBag<T> { @Override public boolean addOccurrences(T element, int occurrences) { int sizeBefore = size; Integer merged = this.backingMap.merge(element, occurrences, (existingCount, e) -> existingCount + e); size = size + occurrences; return sizeBefore != size; } @Override int sizeDistinct(); @O...
@Test public void addOccurrences() { this.testObj.addOccurrences("1", 1); Assert.assertEquals(MutableBag.of("1"), this.testObj); Assert.assertEquals(1, this.testObj.size()); Assert.assertEquals(1, this.testObj.sizeDistinct()); this.testObj.addOccurrences("2", 2); Assert.assertEquals(MutableBag.of("1", "2", "2"), this.t...
HashBag implements MutableBag<T> { @Override public boolean removeOccurrence(T element) { return this.removeOccurrences(element, 1); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void forEachWithIndex(BiConsumer<? ...
@Test public void removeOccurrence() { Assert.assertFalse(this.testObj.removeOccurrence("1")); Assert.assertEquals(MutableBag.empty(), this.testObj); this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertTrue(this.testObj.removeOccurrence("1")); Assert.assertEquals(MutableBag.of("2", "2", "3", "3", "3"), thi...
HashBag implements MutableBag<T> { @Override public boolean removeOccurrences(T element, int occurrences) { int sizeBefore = size; Integer existing = this.backingMap.get(element); if (existing != null) { Integer newCount = existing - occurrences; if (newCount <= 0) { this.backingMap.remove(element); size = size - exist...
@Test public void removeOccurrences() { Assert.assertFalse(this.testObj.removeOccurrences("1", 1)); Assert.assertEquals(MutableBag.empty(), this.testObj); this.testObj.withAll("1", "2", "3", "2", "3", "3"); Assert.assertTrue(this.testObj.removeOccurrences("1", 2)); Assert.assertEquals(MutableBag.of("2", "2", "3", "3", ...
HashBag implements MutableBag<T> { @Override public void forEachWithOccurrences(BiConsumer<? super T, Integer> biConsumer) { this.backingMap.forEach(biConsumer); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Object[] toArray(); void f...
@Test public void forEachWithOccurrences() { MutableList<String> list = MutableList.empty(); this.testObj.withAll("1", "2", "3", "2", "3", "3") .forEachWithOccurrences((each, count) -> list.add(each + count)); Assert.assertEquals(MutableList.of("11", "22", "33"), list); }
HashBag implements MutableBag<T> { @Override public void forEach(Consumer<? super T> consumer) { this.backingMap.forEach((key, count) -> { for (int i = 0; i < count; i++) { consumer.accept(key); } }); } @Override int sizeDistinct(); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o...
@Test public void forEach() { MutableList<String> list = MutableList.empty(); this.testObj.withAll("1", "2", "3", "2", "3", "3") .forEach((each) -> list.add(each)); Assert.assertEquals(MutableList.of("1", "2", "2", "3", "3", "3"), list); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean isEmpty() { return this.BACKING_MULTIMAP.isEmpty(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @...
@Test public void isEmpty() { this.testObj = new UnmodifiableArrayListMultimap(new ArrayListMultimap()); Assert.assertTrue(this.testObj.isEmpty()); this.testObj = new UnmodifiableArrayListMultimap(this.inputMultimap); Assert.assertFalse(this.testObj.isEmpty()); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> get(Object key) { return this.BACKING_MULTIMAP.get(key).asUnmodifiable(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMulti...
@Test public void get() { MutableList<Integer> value = this.testObj.get("A"); Assert.assertEquals(MutableList.of(1, 2, 3, 1), value); Assert.assertEquals(MutableList.empty(), this.testObj.get("C")); Verify.assertThrows(UnsupportedOperationException.class, () -> value.add(6)); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean put(K key, RichIterable<V> value) { throw new UnsupportedOperationException("Not allowed to perform put() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayLi...
@Test public void put() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.put("A", 1)); } @Test public void get_putIterable() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.put("A", MutableList.of(1))); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void putAll(Map<? extends K, ? extends RichIterable<V>> map) { throw new UnsupportedOperationException("Not allowed to perform putAll() on " + UnmodifiableArrayListMultimap.class);...
@Test public void putAll() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.putAll(MutableMap.of("A", MutableList.of(1, 2, 3)))); }
EclipseCollectionsDeckOfCardsAsList { public Bag<Suit> countsBySuit() { return null; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); Immuta...
@Test public void countsBySuit() { Assert.assertEquals( this.jdkDeck.countsBySuit().get(Suit.CLUBS).intValue(), this.ecDeck.countsBySuit().occurrencesOf(Suit.CLUBS)); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public MutableList<V> remove(Object key) { throw new UnsupportedOperationException("Not allowed to perform remove() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMul...
@Test public void remove() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.remove("A")); } @Test public void remove_keyValue() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.remove("A")); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsKey(Object key) { return this.BACKING_MULTIMAP.containsKey(key); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V...
@Test public void containsKey() { Assert.assertTrue(this.testObj.containsKey("A")); Assert.assertTrue(this.testObj.containsKey("B")); Assert.assertFalse(this.testObj.containsKey("C")); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public boolean containsValue(Object value) { return this.BACKING_MULTIMAP.containsValue(value); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMulti...
@Test public void containsValue() { Assert.assertTrue(this.testObj.containsValue(1)); Assert.assertTrue(this.testObj.containsValue(2)); Assert.assertTrue(this.testObj.containsValue(3)); Assert.assertTrue(this.testObj.containsValue(10)); Assert.assertFalse(this.testObj.containsValue(4)); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void clear() { throw new UnsupportedOperationException("Not allowed to perform clear() on " + UnmodifiableArrayListMultimap.class); } UnmodifiableArrayListMultimap(MutableMultimap<...
@Test public void clear() { Verify.assertThrows(UnsupportedOperationException.class, () -> this.testObj.clear()); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public Set<K> keySet() { return this.BACKING_MULTIMAP.keySet(); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultimap<K, V> asUnmodifiable(); @Ove...
@Test public void keySet() { Assert.assertEquals(MutableSet.of("A", "B"), this.testObj.keySet()); }
UnmodifiableArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public void forEach(BiConsumer<K, V> biConsumer) { this.BACKING_MULTIMAP.forEach(biConsumer); } UnmodifiableArrayListMultimap(MutableMultimap<K, V> multimap); @Override MutableListMultima...
@Test public void forEach() { MutableList<String> combined = MutableList.empty(); this.testObj.forEach((key, value) -> combined.add(key + value.toString())); Assert.assertEquals( MutableList.of("A1", "A2", "A3", "A1", "B10", "B10"), combined); }
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { @Override public int size() { return this.size; } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable(); }
@Test public void get_put() { this.testObj.put("A", 1); Assert.assertEquals(MutableList.of(1), this.testObj.get("A")); Assert.assertEquals(1, this.testObj.size()); this.testObj.put("A", 2); Assert.assertEquals(MutableList.of(1, 2), this.testObj.get("A")); Assert.assertEquals(2, this.testObj.size()); this.testObj.put("A...
EclipseCollectionsDeckOfCardsAsList { public Bag<Rank> countsByRank() { return null; } EclipseCollectionsDeckOfCardsAsList(); MutableStack<Card> shuffle(Random random); MutableSet<Card> deal(MutableStack<Card> stack, int count); ImmutableList<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); Immuta...
@Test public void countsByRank() { Assert.assertEquals( this.jdkDeck.countsByRank().get(Rank.TEN).intValue(), this.ecDeck.countsByRank().occurrencesOf(Rank.SEVEN)); }
ArrayListMultimap extends AbstractMutableMultimap<K, V, MutableList<V>> implements MutableListMultimap<K, V> { public static <K, V> ArrayListMultimap<K, V> newMultimap() { return new ArrayListMultimap<>(); } static ArrayListMultimap<K, V> newMultimap(); @Override int size(); MutableListMultimap<K, V> asUnmodifiable();...
@Test public void hashCodeEquals() { this.testObj.putAll(MutableMap.of("A", MutableList.of(1, 2, 3, 1))); this.testObj.putAll(MutableMap.of("B", MutableList.of(10, 10))); ArrayListMultimap<String, Integer> other = ArrayListMultimap.newMultimap(); other.putAll(MutableMap.of("A", MutableList.of(1, 2, 3, 1))); Assert.asse...
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( Deque<C...
@Test public void allCards() { Assert.assertEquals(this.jdk1Deck.getCards(), this.jdk2Deck.getCards()); } @Test public void cardsAreImmutable() { var jdk2Cards = this.jdk2Deck.getCards(); Verify.assertThrows( UnsupportedOperationException.class, () -> jdk2Cards.remove(null)); Verify.assertThrows( UnsupportedOperationEx...
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> diamonds() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( Deque<Card> s...
@Test public void diamonds() { Assert.assertEquals(this.jdk1Deck.diamonds(), this.jdk2Deck.diamonds()); }
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> hearts() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( Deque<Card> shu...
@Test public void hearts() { Assert.assertEquals(this.jdk1Deck.hearts(), this.jdk2Deck.hearts()); }
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> spades() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( Deque<Card> shu...
@Test public void spades() { Assert.assertEquals(this.jdk1Deck.spades(), this.jdk2Deck.spades()); }
JDK8DeckOfCardsAsSortedSet { public SortedSet<Card> clubs() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( Deque<Card> shuf...
@Test public void clubs() { Assert.assertEquals(this.jdk1Deck.clubs(), this.jdk2Deck.clubs()); }
JDK8DeckOfCardsAsList { public List<Card> getCards() { return this.cards; } JDK8DeckOfCardsAsList(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, in...
@Test public void allCards() { Assert.assertEquals(this.jdk1Deck.getCards(), this.jdk2Deck.getCards()); } @Test public void cardsAreImmutable() { var jdk2Cards = this.jdk2Deck.getCards(); Verify.assertThrows( UnsupportedOperationException.class, () -> jdk2Cards.remove(0)); Verify.assertThrows( UnsupportedOperationExcep...
JDK8DeckOfCardsAsSortedSet { public Set<Card> deal(Deque<Card> deque, int count) { Set<Card> hand = new HashSet<>(); IntStream.range(0, count).forEach(i -> hand.add(deque.pop())); return hand; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card...
@Test public void deal() { Deque<Card> jdk1Shuffle = this.jdk1Deck.shuffle(new Random(1)); Deque<Card> jdk2Shuffle = this.jdk2Deck.shuffle(new Random(1)); Set<Card> jdk1Hand = this.jdk1Deck.deal(jdk1Shuffle, 5); Set<Card> jdk2Hand = this.jdk2Deck.deal(jdk2Shuffle, 5); Assert.assertEquals(jdk1Hand, jdk2Hand); }
JDK8DeckOfCardsAsSortedSet { public List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand) { Deque<Card> shuffled = this.shuffle(random); return this.dealHands(shuffled, hands, cardsPerHand); } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int co...
@Test public void shuffleAndDealHands() { List<Set<Card>> jdk1Hands = this.jdk1Deck.shuffleAndDeal(new Random(1), 5, 5); List<Set<Card>> jdk2Hands = this.jdk2Deck.shuffleAndDeal(new Random(1), 5, 5); Assert.assertEquals(jdk1Hands, jdk2Hands); }
JDK8DeckOfCardsAsSortedSet { public List<Set<Card>> dealHands( Deque<Card> shuffled, int hands, int cardsPerHand) { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); L...
@Test public void dealHands() { Deque<Card> jdk1Shuffled = this.jdk1Deck.shuffle(new Random(1)); Deque<Card> jdk2Shuffled = this.jdk2Deck.shuffle(new Random(1)); List<Set<Card>> jdk1Hands = this.jdk1Deck.dealHands(jdk1Shuffled, 5, 5); List<Set<Card>> jdk2Hands = this.jdk2Deck.dealHands(jdk2Shuffled, 5, 5); Assert.asser...
JDK8DeckOfCardsAsSortedSet { public Map<Suit, SortedSet<Card>> getCardsBySuit() { return this.cardsBySuit; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHan...
@Test public void cardsBySuit() { Map<Suit, SortedSet<Card>> jdk1CardsBySuit = this.jdk1Deck.getCardsBySuit(); Map<Suit, SortedSet<Card>> jdk2CardsBySuit = this.jdk2Deck.getCardsBySuit(); Assert.assertEquals(jdk1CardsBySuit.get(Suit.CLUBS), jdk2CardsBySuit.get(Suit.CLUBS)); } @Test public void cardsBySuitIsImmutable() ...
JDK8DeckOfCardsAsSortedSet { public Map<Suit, Long> countsBySuit() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( Deque<Car...
@Test public void countsBySuit() { Assert.assertEquals( this.jdk1Deck.countsBySuit().get(Suit.CLUBS), this.jdk2Deck.countsBySuit().get(Suit.CLUBS)); }
JDK8DeckOfCardsAsSortedSet { public Map<Rank, Long> countsByRank() { return null; } JDK8DeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( Deque<Car...
@Test public void countsByRank() { Assert.assertEquals( this.jdk1Deck.countsByRank().get(Rank.TEN), this.jdk2Deck.countsByRank().get(Rank.TEN)); }
VavrDeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> de...
@Test public void allCards() { Assert.assertEquals(this.jdkDeck.getCards(), this.vavrDeck.getCards().toJavaSet()); }
VavrDeckOfCardsAsSortedSet { public SortedSet<Card> diamonds() { return null; } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHand...
@Test public void diamonds() { Assert.assertEquals(this.jdkDeck.diamonds(), this.vavrDeck.diamonds().toJavaSet()); }
VavrDeckOfCardsAsSortedSet { public SortedSet<Card> hearts() { return null; } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(...
@Test public void hearts() { Assert.assertEquals(this.jdkDeck.hearts(), this.vavrDeck.hearts().toJavaSet()); }
VavrDeckOfCardsAsSortedSet { public SortedSet<Card> spades() { return null; } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(...
@Test public void spades() { Assert.assertEquals(this.jdkDeck.spades(), this.vavrDeck.spades().toJavaSet()); }
VavrDeckOfCardsAsSortedSet { public SortedSet<Card> clubs() { return null; } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( ...
@Test public void clubs() { Assert.assertEquals(this.jdkDeck.clubs(), this.vavrDeck.clubs().toJavaSet()); }
VavrDeckOfCardsAsSortedSet { public Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count) { Set<Card> hand = HashSet.empty(); for (int i = 0; i < count; i++) { Tuple2<Card, ? extends List<Card>> cardTuple2 = stack.pop2(); stack = cardTuple2._2(); hand = hand.add(cardTuple2._1()); } return Tuple.of(h...
@Test public void deal() { Deque<Card> jdkShuffle = this.jdkDeck.shuffle(new Random(1)); io.vavr.collection.List<Card> vavrShuffle = this.vavrDeck.shuffle(new Random(1)); Set<Card> jdkHand = this.jdkDeck.deal(jdkShuffle, 5); Set<Card> vavrHand = this.vavrDeck.deal(vavrShuffle, 5)._1().toJavaSet(); Assert.assertEquals(j...
VavrDeckOfCardsAsSortedSet { public List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand) { List<Card> shuffled = this.shuffle(random); return this.dealHands(shuffled, hands, cardsPerHand); } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> de...
@Test public void shuffleAndDealHands() { List<Set<Card>> jdkHands = this.jdkDeck.shuffleAndDeal(new Random(1), 5, 5); io.vavr.collection.List<io.vavr.collection.Set<Card>> vavrHands = this.vavrDeck.shuffleAndDeal(new Random(1), 5, 5); Assert.assertEquals(jdkHands.get(0), vavrHands.get(0).toJavaSet()); Assert.assertEqu...
VavrDeckOfCardsAsSortedSet { public List<Set<Card>> dealHands( List<Card> shuffled, int hands, int cardsPerHand) { return null; } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count); List<Set<Card>> shuffleAndDeal(Random random, int ...
@Test public void dealHands() { Deque<Card> jdkShuffled = this.jdkDeck.shuffle(new Random(1)); io.vavr.collection.List<Card> vavrShuffled = this.vavrDeck.shuffle(new Random(1)); List<Set<Card>> jdkHands = this.jdkDeck.dealHands(jdkShuffled, 5, 5); io.vavr.collection.List<io.vavr.collection.Set<Card>> vavrHands = this.v...
VavrDeckOfCardsAsSortedSet { public Map<Suit, ? extends SortedSet<Card>> getCardsBySuit() { return this.cardsBySuit; } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int ...
@Test public void cardsBySuit() { Map<Suit, SortedSet<Card>> jdkCardsBySuit = this.jdkDeck.getCardsBySuit(); io.vavr.collection.Map<Suit, ? extends io.vavr.collection.SortedSet<Card>> vavrCardsBySuit = this.vavrDeck.getCardsBySuit(); Assert.assertEquals(jdkCardsBySuit.get(Suit.CLUBS), vavrCardsBySuit.get(Suit.CLUBS).ge...
VavrDeckOfCardsAsSortedSet { public Map<Suit, Long> countsBySuit() { return null; } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> deal...
@Test public void countsBySuit() { Assert.assertEquals( this.jdkDeck.countsBySuit().get(Suit.CLUBS), this.vavrDeck.countsBySuit().get(Suit.CLUBS).get()); }
VavrDeckOfCardsAsSortedSet { public Map<Rank, Long> countsByRank() { return null; } VavrDeckOfCardsAsSortedSet(); List<Card> shuffle(Random random); Tuple2<Set<Card>, ? extends List<Card>> deal(List<Card> stack, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> deal...
@Test public void countsByRank() { Assert.assertEquals( this.jdkDeck.countsByRank().get(Rank.TEN), this.vavrDeck.countsByRank().get(Rank.TEN).get()); }
ApacheCommonsDeckOfCardsAsSortedSet { public SortedSet<Card> getCards() { return this.cards; } ApacheCommonsDeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( ...
@Test public void allCards() { Assert.assertEquals(this.jdkDeck.getCards(), this.acDeck.getCards()); } @Test public void cardsAreImmutable() { var acCards = this.acDeck.getCards(); Verify.assertThrows( UnsupportedOperationException.class, () -> acCards.remove(null)); Verify.assertThrows( UnsupportedOperationException.c...
JDK8DeckOfCardsAsList { public List<Card> diamonds() { return null; } JDK8DeckOfCardsAsList(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands(Deque<Card> shuffled, int hands, int card...
@Test public void diamonds() { Assert.assertEquals(this.jdk1Deck.diamonds(), this.jdk2Deck.diamonds()); }
ApacheCommonsDeckOfCardsAsSortedSet { public SortedSet<Card> diamonds() { return null; } ApacheCommonsDeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( ...
@Test public void diamonds() { Assert.assertEquals(this.jdkDeck.diamonds(), this.acDeck.diamonds()); }
ApacheCommonsDeckOfCardsAsSortedSet { public SortedSet<Card> hearts() { return null; } ApacheCommonsDeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( ...
@Test public void hearts() { Assert.assertEquals(this.jdkDeck.hearts(), this.acDeck.hearts()); }
ApacheCommonsDeckOfCardsAsSortedSet { public SortedSet<Card> spades() { return null; } ApacheCommonsDeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( ...
@Test public void spades() { Assert.assertEquals(this.jdkDeck.spades(), this.acDeck.spades()); }
ApacheCommonsDeckOfCardsAsSortedSet { public SortedSet<Card> clubs() { return null; } ApacheCommonsDeckOfCardsAsSortedSet(); Deque<Card> shuffle(Random random); Set<Card> deal(Deque<Card> deque, int count); List<Set<Card>> shuffleAndDeal(Random random, int hands, int cardsPerHand); List<Set<Card>> dealHands( ...
@Test public void clubs() { Assert.assertEquals(this.jdkDeck.clubs(), this.acDeck.clubs()); }