src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
Sentence implements Serializable, Iterable<Annotation> { public DependencyTreeNode[] dependencyParseTree() { if (tokenAnnotations.length == 0 || !tokenAnnotations[0].hasDependencyParent()) return new DependencyTreeNode[0]; SimpleDependencyTreeNode[] nodes = new SimpleDependencyTreeNode[tokenAnnotations.length]; for (in... | @Test public void testDependencyParseTree() { Sentence sentence = new Sentence(0, 100, 7); for (int i = 0; i < TEST_PARSED_SENTENCES.length; ++i) sentence.addAnnotation( i, annotationFromCoNLL(TEST_PARSED_SENTENCES[i])); DependencyTreeNode[] tree = sentence.dependencyParseTree(); assertEquals(TEST_PARSED_SENTENCES.leng... |
Sentence implements Serializable, Iterable<Annotation> { public StringPair[] taggedTokens() { StringPair[] taggedTokens = new StringPair[tokenAnnotations.length]; for (int i = 0; i < taggedTokens.length; ++i) taggedTokens[i] = new StringPair( tokenAnnotations[i].word(), tokenAnnotations[i].pos()); return taggedTokens; ... | @Test public void testTaggedTokens() { Sentence sentence = makeSentence(0, 4, TOKEN_INFO, RANGES); StringPair[] taggedPairs = sentence.taggedTokens(); assertEquals(TOKEN_INFO.length, taggedPairs.length); for (int i = 0; i < TOKEN_INFO.length; ++i) { assertEquals(TOKEN_INFO[i][0], taggedPairs[i].x); assertEquals(TOKEN_I... |
NetworkConfluency { public double computeInitialAgreement() { return computeKappaScore( info1.edges, info2.edges, numNodes); } NetworkConfluency(String matrixFile1,
String matrixFile2,
Format format); NetworkConfluency(SparseMatrix matrix1, SparseMatrix matrix... | @Test public void testInitialAgreement() { double[][] v1 = new double[][] { {1, 1, 0, 0, 1, 0}, {0, 0, 1, 0, 1, 0}, {0, 1, 0, 0, 0, 1}, {0, 1, 1, 1, 0, 0}, {1, 0, 1, 0, 0, 1}, {1, 1, 0, 0, 1, 1}, }; double[][] v2 = new double[][] { {1, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 1, 0}, {0, 1, 1, 0, 0, 1}, {0, 1, 1, 1, 1, 0}, {1, 0, 1... |
BaseSynset implements Synset { public PartsOfSpeech getPartOfSpeech() { return pos; } BaseSynset(String synsetName); BaseSynset(int offset, PartsOfSpeech pos); BaseSynset(PartsOfSpeech pos); void addMorphyMapping(String original, String lemma); int getSenseNumber(); void setSenseNumber(int senseNumber); String getNam... | @Test public void testConstructor() { Synset synset = new BaseSynset(PartsOfSpeech.NOUN); assertEquals(PartsOfSpeech.NOUN, synset.getPartOfSpeech()); } |
StringUtils { public static int tokenOverlapExp(String[] tokens1, String[] tokens2) { int index1 = 0; int index2 = 0; int score = 0; for (int i = 0; i < tokens1.length; ++i) for (int j = 0; j < tokens2.length; ++j) if (tokens1[i].equals(tokens2[j])) score += Math.pow(findOverlap(tokens1, i, tokens2, j), 2); return scor... | @Test public void testTokenOverlapExpNoSequence() { String[] tokens1 = {"the", "cat", "has", "a", "brown", "bag"}; String[] tokens2 = {"bag", "dog", "was", "cat", "blah", "bag"}; assertEquals(3, StringUtils.tokenOverlapExp(tokens1, tokens2)); }
@Test public void testTokenOverlapExpBoundedSequence() { String[] tokens1 =... |
BaseSynset implements Synset { public void merge(Synset synset) { if (pos != synset.getPartOfSpeech()) throw new IllegalArgumentException( "Cannot merge synsets with different parts of speech."); Set<Duple<String, Synset>> toRemove = new HashSet<Duple<String, Synset>>(); for (String relation : getKnownRelationTypes()) ... | @Test (expected=IllegalArgumentException.class) public void testMergeBadPos() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.VERB); s1.merge(s2); } |
ResnickSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { List<Synset> subsumers = SynsetRelations.lowestCommonHypernyms( synset1, synset2); if (subsumers.size() == 0) return 0; double bestIC = 0; for (Synset subsumer : subsumers) bestIC = Math.max(bestIC, ic.information... | @Test public void testNoSubsumer() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); SynsetSimilarity sim = new ResnickSimilarity(null); assertEquals(0, sim.similarity(s1, s2), .00001); }
@Test public void testSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN);... |
LeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { String[] gloss1 = synset1.getGloss().split("\\s+"); String[] gloss2 = synset2.getGloss().split("\\s+"); return StringUtils.tokenOverlap(gloss1, gloss2); } double similarity(Synset synset1, Synset synset2); } | @Test public void testLeskSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); s1.setDefinition("how now brown cow"); s2.setDefinition("how now sad meow"); SynsetSimilarity sim = new LeskSimilarity(); assertEquals(2, sim.similarity(s1, s2), .00001); } |
LinSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim.similarity(synset1, synset2); return (2d * icSubsumer) / (ic1 ... | @Test public void testNoSubsumer() { MockIC ic = new MockIC(); Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); SynsetSimilarity sim = new LinSimilarity(ic); assertEquals(0, sim.similarity(s1, s2), .00001); }
@Test public void testSimilarity() { MockIC ic = new MockIC(); S... |
WuPalmerSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Synset subsumer = SynsetRelations.lowestCommonHypernym( synset1, synset2); if (subsumer == null) return 0; double depth = subsumer.getMaxDepth() + 1; if (subsumer.getPartOfSpeech() == PartsOfSpeech.NOUN) depth++;... | @Test public void testNoSubsumer() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); SynsetSimilarity sim = new WuPalmerSimilarity(); assertEquals(0, sim.similarity(s1, s2), .00001); }
@Test public void testNounSimilarity() { Synset subsumer = new BaseSynset(PartsOfSpeech... |
JiangConrathSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.equals(synset2)) return Double.MAX_VALUE; double ic1 = ic.informationContent(synset1); double ic2 = ic.informationContent(synset2); if (ic1 == -1 || ic2 == -1) return 0; double icSubsumer = resSim... | @Test public void testNoSubsumer() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); SynsetSimilarity sim = new JiangConrathSimilarity(null); assertEquals(Double.MAX_VALUE, sim.similarity(s1, s1), .00001); }
@Test public void testSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(... |
LeacockChodorowSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { if (synset1.getPartOfSpeech() != synset2.getPartOfSpeech()) return 0; int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); int distance = SynsetRelations.shortestPathDistance(synset1, synset2); r... | @Test public void testWrongPos() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.VERB); SynsetSimilarity sim = new LeacockChodorowSimilarity(null); assertEquals(0, sim.similarity(s1, s2), .0001); }
@Test public void testSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.N... |
LeacockChodorowScaledSimilarity extends LeacockChodorowSimilarity { public double similarity(Synset synset1, Synset synset2) { double lchSim = super.similarity(synset1, synset2); int maxDepth = wordnet.getMaxDepth(synset1.getPartOfSpeech()); double maxSim = -1 * Math.log(1/(2d* maxDepth)); return lchSim / maxSim; } Lea... | @Test public void testWrongPos() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.VERB); MockReader reader = new MockReader(); SynsetSimilarity sim = new LeacockChodorowScaledSimilarity(reader); assertEquals(0, sim.similarity(s1, s2), .0001); }
@Test public void testSimilarity(... |
ExtendedLeskSimilarity implements SynsetSimilarity { public double similarity(Synset synset1, Synset synset2) { Set<Synset> synsets1 = Sets.newHashSet(synset1.allRelations()); synsets1.add(synset1); Set<Synset> synsets2 = Sets.newHashSet(synset2.allRelations()); synsets2.add(synset2); double score = 0; for (Synset s1 :... | @Test public void testLeskSimilarity() { Synset s1 = new BaseSynset(PartsOfSpeech.NOUN); Synset s2 = new BaseSynset(PartsOfSpeech.NOUN); Synset p2 = new BaseSynset(PartsOfSpeech.NOUN); s1.setDefinition("how now brown cow"); s2.setDefinition("how now sad meow"); p2.setDefinition("cow sad sad"); s2.addRelation(Relation.H... |
ExtendedLeskWordSenseDisambiguation extends LeskWordSenseDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new ExtendedLeskSimilarity(); } void setup(OntologyReader reader); String toString(); } | @Test public void testDisambiguation() { WordSenseDisambiguation wsdAlg = new ExtendedLeskWordSenseDisambiguation(); Sentence sentences = getSentences(TEST_SENTENCE, TEST_POS); wsdAlg.setup(new GenericMockReader(SYNSET_DATA)); Sentence sent = wsdAlg.disambiguate(sentences); Sentence expected = sentences; assertEquals(e... |
LeskWordSenseDisambiguation extends SlidingWindowDisambiguation { public void setup(OntologyReader reader) { this.reader = reader; this.sim = new LeskSimilarity(); } void setup(OntologyReader reader); String toString(); } | @Test public void testDisambiguation() { WordSenseDisambiguation wsdAlg = new LeskWordSenseDisambiguation(); Sentence sentences = getSentences(TEST_SENTENCE, TEST_POS); wsdAlg.setup(new GenericMockReader(SYNSET_DATA)); Sentence sent = wsdAlg.disambiguate(sentences); Sentence expected = sentences; assertEquals(expected.... |
CombinedSet extends AbstractSet<T> { public int size() { int size = 0; for (Set<T> set : sets) size += set.size(); return size; } CombinedSet(Set<T>...sets); CombinedSet(Collection<Set<T>> setCollection); Iterator<T> iterator(); int size(); } | @Test public void testCombinedSize() { Set<String> set1 = new HashSet<String>(); for (String s : array1) set1.add(s); Set<String> set2 = new HashSet<String>(); for (String s : array2) set2.add(s); Set<String> combined = new CombinedSet<String>(set1, set2); assertEquals(6, combined.size()); } |
PersonalizedPageRankWSD extends SlidingWindowDisambiguation { public void setup(OntologyReader wordnet) { this.wordnet = wordnet; synsetMap = Maps.newHashMap(); synsetList = Lists.newArrayList(); for (String lemma : wordnet.wordnetTerms()) { for (Synset synset : wordnet.getSynsets(lemma)) if (!synsetMap.containsKey(syn... | @Test public void testDisambiguation() { WordSenseDisambiguation wsdAlg = new PersonalizedPageRankWSD(); Sentence sentences = getSentences(TEST_SENTENCE, TEST_POS); LinkedMockReader reader = new LinkedMockReader(SYNSET_DATA); for (String[] synsetLink : SYNSET_LINKS) reader.connectSynsets(synsetLink[0], synsetLink[1], "... |
CombinedSet extends AbstractSet<T> { public Iterator<T> iterator() { List<Iterator<T>> iters = new ArrayList<Iterator<T>>(); for (Set<T> set : sets) iters.add(set.iterator()); return new CombinedIterator<T>(iters); } CombinedSet(Set<T>...sets); CombinedSet(Collection<Set<T>> setCollection); Iterator<T> iterator(); int... | @Test public void testIterator() { Set<String> set1 = new HashSet<String>(); for (String s : array1) set1.add(s); Set<String> set2 = new HashSet<String>(); for (String s : array2) set2.add(s); Set<String> combined = new CombinedSet<String>(set1, set2); Iterator<String> comboIter = combined.iterator(); Iterator<String> ... |
ExtendedMap extends AbstractMap<K, V> { public V put(K key, V value) { if (baseMap.containsKey(key)) throw new IllegalArgumentException("Should not reinsert keys"); return extendedMap.put(key, value); } ExtendedMap(Map<K, V> baseMap); Set<Map.Entry<K, V>> entrySet(); V get(Object key); V put(K key, V value); } | @Test public void testPut() { Map<String,String> extendedMap = new ExtendedMap<String, String>(map1); for (Map.Entry<String, String> s : map2.entrySet()) assertNull(extendedMap.put(s.getKey(), s.getValue())); assertEquals(3, map1.size()); } |
ExtendedMap extends AbstractMap<K, V> { public V get(Object key) { V value = baseMap.get(key); return (value != null) ? value : extendedMap.get(key); } ExtendedMap(Map<K, V> baseMap); Set<Map.Entry<K, V>> entrySet(); V get(Object key); V put(K key, V value); } | @Test public void testGet() { Map<String,String> extendedMap = new ExtendedMap<String, String>(map1); for (String key : map1.keySet()) assertEquals(map1.get(key), extendedMap.get(key)); for (Map.Entry<String, String> s : map2.entrySet()) extendedMap.put(s.getKey(), s.getValue()); for (String key : map1.keySet()) assert... |
VideoIndexUtils { public static VideoIndex resolve(VideoIndex videoIndex, Media media) { VideoIndex vi = videoIndex; if (videoIndex.getElapsedTime().isEmpty() && videoIndex.getTimestamp().isPresent()) { Instant endTimestamp = media.getStartTimestamp().plus(media.getDuration()); Instant timestamp = videoIndex.getTimesta... | @Test public void resolveAddElapsedTimeTest() { var et = Duration.ofMinutes(2); var ts = now.plus(et); var vi = new VideoIndex(ts); var rvi = VideoIndexUtils.resolve(vi, media1); assertTrue(rvi.getTimestamp().isPresent()); assertEquals(ts, rvi.getTimestamp().get()); assertTrue(rvi.getElapsedTime().isPresent()); assertE... |
Pager implements Runnable { public Pager(BiFunction<Long, Long, T> fetchFn, Long limit, Long pageSize) { Function<RequestPager.Page, T> fn = (page) -> { try { return fetchFn.apply(page.getLimit(), page.getOffset()); } catch (Exception e) { Long start = page.getOffset(); Long end = start + page.getLimit(); throw new Run... | @Test public void testPager() { var data = new ArrayList<Integer>(); for (var i = 0; i < 1000; i++) { data.add(i); } var pager = new Pager<>((limit, offset) -> { var start = offset; Long end = limit + offset; if (start > data.size()) { start = (long) data.size() - 1; } if (end >= data.size()) { end = (long) data.size()... |
AVFImageCaptureService implements SelectableImageCaptureService { @Override public Framegrab capture(File file) { Framegrab framegrab = new Framegrab(); start(); Optional<Image> imageOpt = imageCapture.capture(file, Duration.ofSeconds(10)); if (imageOpt.isPresent()) { framegrab.setImage(imageOpt.get()); MediaPlayer<? e... | @Ignore @Test public void testImageCapture() throws Exception { AVFImageCapture ic = new AVFImageCapture(); String[] devices = ic.videoDevicesAsStrings(); if (devices.length > 0) { ic.startSessionWithNamedDevice(devices[0]); Path path = Paths.get("target", getClass().getSimpleName() + "-0-" + Instant.now() + ".png"); O... |
Initializer { public static Path getSettingsDirectory() { if (settingsDirectory == null) { String home = System.getProperty("user.home"); Path path = Paths.get(home, ".vars"); settingsDirectory = createDirectory(path); if (settingsDirectory == null) { log.warn("Failed to create settings directory at " + path); } } retu... | @Test public void getSettingsDirectoryTest() { Path path = Initializer.getSettingsDirectory(); assertNotNull("The Settings directory was null", path); assertTrue("The settings directory does not exist", Files.exists(path)); } |
Initializer { public static UIToolBox getToolBox() { if (toolBox == null) { Services services = ServicesBuilder.build(Initializer.getConfig()); ResourceBundle bundle = ResourceBundle.getBundle("i18n", Locale.getDefault()); LessCSSLoader lessLoader = new LessCSSLoader(); String stylesheet = lessLoader.loadLess(Initializ... | @Ignore @Test public void getToolBoxTest() throws Exception { UIToolBox toolBox = Initializer.getToolBox(); assertNotNull("UIToolBox was null", toolBox); Data data = toolBox.getData(); assertNotNull("Data in toolbox was null", data); Services services = toolBox.getServices(); assertNotNull("Services in toolbox was null... |
GraywaterAdapter extends RecyclerView.Adapter<VH> { public void add(@NonNull final T item) { add(mItems.size(), item, true); } @Override int getItemViewType(final int position); @Override VH onCreateViewHolder(final ViewGroup parent, final int viewType); @Override @SuppressLint("RecyclerView") void onBindViewHolder(fi... | @Test public void testAdd() throws Exception { final TestAdapter adapter = new TestAdapter(); adapter.add("one"); assertEquals(2, adapter.getItemCount()); adapter.add("two"); assertEquals(4, adapter.getItemCount()); adapter.add("three"); assertEquals(6, adapter.getItemCount()); } |
GraywaterAdapter extends RecyclerView.Adapter<VH> { @Nullable public T remove(final int itemPosition) { return remove(itemPosition, true); } @Override int getItemViewType(final int position); @Override VH onCreateViewHolder(final ViewGroup parent, final int viewType); @Override @SuppressLint("RecyclerView") void onBin... | @Test public void testRemove() throws Exception { final TestAdapter adapter = new TestAdapter(); adapter.add("zero"); adapter.add("one"); adapter.add("two"); adapter.add("three"); adapter.add("four"); adapter.add("five"); adapter.remove(0); assertEquals(2 * 5, adapter.getItemCount()); adapter.remove(4); assertEquals(2 ... |
GraywaterAdapter extends RecyclerView.Adapter<VH> { @Override public int getItemViewType(final int position) { return internalGetItemViewType(position); } @Override int getItemViewType(final int position); @Override VH onCreateViewHolder(final ViewGroup parent, final int viewType); @Override @SuppressLint("RecyclerVie... | @Test public void testGetItemViewType() throws Exception { final TestAdapter adapter = new TestAdapter(); adapter.add(Uri.parse("https: assertEquals(3, adapter.getItemCount()); adapter.add("one"); assertEquals(5, adapter.getItemCount()); adapter.add(Uri.parse("http: assertEquals(8, adapter.getItemCount()); adapter.add(... |
GraywaterAdapter extends RecyclerView.Adapter<VH> { public void clear() { mItems.clear(); mBinderListCache.clear(); mViewHolderToItemPositionCache.clear(); mItemPositionToFirstViewHolderPositionCache.clear(); mViewHolderPreparedCache.clear(); mPreviousBoundViewHolderPosition = NO_PREVIOUS_BOUND_VIEWHOLDER; } @Override... | @Test public void testClear() throws Exception { final TestAdapter adapter = new TestAdapter(); final Uri tumblrUri = Uri.parse("https: adapter.add(tumblrUri); assertEquals(3, adapter.getItemCount()); adapter.add("one"); assertEquals(5, adapter.getItemCount()); adapter.add(Uri.parse("http: assertEquals(8, adapter.getIt... |
ZNodePath extends ZNodeLabelVector { public static String canonicalize(final String path) { final int length = path.length(); int lastSlash = -1; StringBuilder builder = null; for (int i=0; i<length; ++i) { char c = path.charAt(i); if ((c == SLASH) || (i == length - 1)) { if (i > 0) { if ((c == SLASH) && (lastSlash == ... | @Test public void testCanonicalize() { assertEquals("/", ZNodePath.canonicalize("/")); assertEquals("/", ZNodePath.canonicalize(" assertEquals("/", ZNodePath.canonicalize(" assertEquals("/a", ZNodePath.canonicalize("/a")); assertEquals("/a", ZNodePath.canonicalize("/a/")); assertEquals("/", ZNodePath.canonicalize("/.")... |
IterableNullChecker { public static <T> Iterable<T> checkNotContainsNull(final Iterable<T> iterable, final String errorMessage) { checkNotNull(iterable, "Argument \'iterable\' cannot be null."); checkNotNull(errorMessage, "Argument \'errorMessage\' cannot be null."); for (final Object o : iterable) { checkNotNull(o, er... | @Test(expected = IllegalArgumentException.class) public void testCheckNotContainsNull_nullIterable() { IterableNullChecker.checkNotContainsNull(null, ""); }
@Test public void testCheckNotContainsNull_emptyIterable() { IterableNullChecker.checkNotContainsNull(new ArrayList<>(), ""); }
@Test(expected = IllegalArgumentExc... |
CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public boolean takeItem(Player player, int id, int amount) { ItemStack IS = new ItemStack(id, amount); if (!player.getInventory().containsAtLeast(IS, amount)) return false; player.getInventory().removeItem(IS); return true; } CommonF... | @SuppressWarnings("deprecation") @Test public void testTakeItem() { ItemStack IS = new ItemStack(Material.STONE, 64); ItemStack IS2 = new ItemStack(Material.STONE, 64, (short) 1); FakeInventory inv = fInventory(this, IS, IS2); Player mockPlayer = Mockito.mock(Player.class); PlayerInventory mockInventory = preparePlayer... |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String currentAreaAt(Location location) { String[] areaNames = currentAreasAt(location); return areaNames.length > 0 ? areaNames[0] : null; } AbstractCommonFunctions(TriggerReacto... | @Test public void testCurrentAreaAt() { } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreas(Entity entity) { return currentAreasAt(entity.getLocation()); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated a... | @Test public void testCurrentAreas() { } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String[] currentAreasAt(Location location) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); String[] names = areaManager.getAreas(LocationUtil.convertToSimpleLo... | @Test public void testCurrentAreasAt() { } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public List<Entity> getEntitiesInArea(String areaTriggerName) { AbstractAreaTriggerManager areaManager = plugin.getAreaManager(); AreaTrigger trigger = areaManager.getArea(areaTriggerNam... | @Test public void testGetEntitiesInArea() { } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String color(String str) { return ChatColor.translateAlternateColorCodes('&', str); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated a... | @Test public void testColor() { Assert.assertEquals(ChatColor.RED + "My message", fn.color("&cMy message")); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Color bukkitColor(int red, int green, int blue) { return Color.fromRGB(red, green, blue); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprec... | @Test public void testBukkitColor() { Color expect = Color.fromRGB(3, 6, 8); Color result = fn.bukkitColor(3, 6, 8); Assert.assertEquals(expect.asBGR(), result.asBGR()); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Deprecated public abstract ItemStack item(int type, int amount, int data); AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstract boolean t... | @Test public abstract void testItem(); |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getItemTitle(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return ""; String dispName = IM.getDisplayName(); return dispName == null ? "" : dispName; } Ab... | @Test public void testGetItemTitle() { ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> "abc").when(mockItemMeta).getDisplayName(); Assert.assertEquals("abc", fn.getItemTitle(IS)); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setItemTitle(ItemStack IS, String title) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; IM.... | @Test public void testSetItemTitle() { ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> { title = invocation.getArgument(0); return null; }).when(mockItemMeta).setDisplayName(Mockito.anyString()); fn.setItemTitle(IS, "xyz"); Assert.assertEquals("xyz", title); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public boolean hasLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return false; List<String> lores = IM.getLore(); if (lores == null) return false; retu... | @Test public void testHasLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); Assert.assertTrue(fn.hasLore(IS, "abab")); Assert.assertFalse(fn.hasLore(IS, "hoho")); } |
CommonFunctions extends AbstractCommonFunctions implements SelfReference { @Deprecated public ItemStack item(int type, int amount, int data) { return new ItemStack(type, amount, (short) data); } CommonFunctions(TriggerReactorCore plugin); @Deprecated boolean takeItem(Player player, int id, int amount); boolean takeItem... | @SuppressWarnings("deprecation") @Test public void testItem() { ItemStack IS = new ItemStack(Material.STONE, 64); ItemStack IS2 = new ItemStack(Material.STONE, 63, (short) 1); Assert.assertTrue(isEqual(IS, fn.item("STONE", 64))); Assert.assertTrue(isEqual(IS2, fn.item("STONE", 63, 1))); Assert.assertTrue(isEqual(IS, fn... |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String getLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return null; List<String> lores = IM.getLore(); if (lores == null) return null; if (index... | @Test public void testGetLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); Assert.assertEquals("abab", fn.getLore(IS, 0)); Assert.assertEquals("cdcd", fn.getLore(IS, 1))... |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void addLore(ItemStack IS, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Stri... | @Test public void testAddLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); fn.addLore(IS, "efef"); Assert.assertEquals(3, lores.size()); Assert.assertEquals("efef", lore... |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void setLore(ItemStack IS, int index, String lore) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return... | @Test public void testSetLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); fn.setLore(IS, 0, "pqpq"); Assert.assertEquals("pqpq", lores.get(0)); fn.setLore(IS, 5, "ffee"... |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void removeLore(ItemStack IS, int index) { ItemMeta IM = IS.getItemMeta(); if (IM == null) IM = Bukkit.getItemFactory().getItemMeta(IS.getType()); if (IM == null) return; List<Str... | @Test public void testRemoveLore() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); lores.add("efef"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); fn.removeLore(IS, 2); Assert.assertEquals(2, lores.size()); Assert.asser... |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public void clearLore(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return; IM.setLore(new ArrayList<>()); IS.setItemMeta(IM); } AbstractCommonFunctions(TriggerReactorC... | @Test public void testClearLore() { ItemStack IS = new ItemStack(Material.STONE); ArgumentCaptor<List> captor = ArgumentCaptor.forClass(List.class); fn.clearLore(IS); Mockito.verify(mockItemMeta).setLore(captor.capture()); Assert.assertEquals(0, captor.getValue().size()); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public int loreSize(ItemStack IS) { ItemMeta IM = IS.getItemMeta(); if (IM == null) return 0; List<String> lores = IM.getLore(); if (lores == null) return 0; return lores.size(); } Abstr... | @Test public void testLoreSize() { List<String> lores = new ArrayList<>(); lores.add("abab"); lores.add("cdcd"); lores.add("efef"); ItemStack IS = new ItemStack(Material.STONE); Mockito.doAnswer(invocation -> lores).when(mockItemMeta).getLore(); Assert.assertEquals(3, fn.loreSize(IS)); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { @Override public String formatCurrency(double money, String locale1, String locale2) { Locale locale = new Locale(locale1, locale2); NumberFormat currencyFormatter = NumberFormat.getCurr... | @Test public void testFormatCurrency() { Assert.assertEquals("$3,234,463.44", fn.formatCurrency(3234463.44)); Assert.assertEquals("$3,234,463.44", fn.formatCurrency(3234463.44, "en", "US")); Assert.assertEquals("\u00a33,234,463.44", fn.formatCurrency(3234463.44, "en", "GB")); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block getTargetBlock(Player player, int maxDistance) { return player.getTargetBlock(null, maxDistance); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String ... | @Test public void testGetTargetBlock() { fn.getTargetBlock(mockPlayer, 30); Mockito.verify(mockPlayer).getTargetBlock(null, 30); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public ItemStack headForName(String targetName) { return headForName(targetName, 1); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstrac... | @Test public abstract void testHeadForName(); |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public abstract ItemStack headForValue(String textureValue); AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstract boolean takeItem(Player ... | @Test public abstract void testHeadForValue(); |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Location location(String world, double x, double y, double z) { return location(world, x, y, z, 0.0, 0.0); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(Stri... | @Test public void testLocation() { Location loc1 = new Location(mockWorld, 1, 2, 3); Location loc2 = new Location(mockWorld, 4, 5, 6, 0.5F, 0.6F); Mockito.when(mockWorld.getName()).thenReturn("test"); Assert.assertEquals(loc1, fn.location("test", 1, 2, 3)); Mockito.when(mockWorld.getName()).thenReturn("test2"); Assert.... |
BukkitMigrationHelper implements IMigrationHelper { @Override public void migrate(IConfigSource current) { traversal(null, oldConfig.getValues(false), current::put); if (oldFile.exists()) oldFile.renameTo(new File(oldFile.getParentFile(), "config.yml.bak")); } BukkitMigrationHelper(FileConfiguration oldConfig, File old... | @Test public void migrate() { IConfigSource mockSource = mock(IConfigSource.class); FileConfiguration mockConfig = YamlConfiguration.loadConfiguration(new StringReader("" + "Mysql:\n" + " Enable: false\n" + " Address: 127.0.0.1:3306\n" + " DbName: TriggerReactor\n" + " UserName: root\n" + " Password: '1234'\n" + " Deep... |
Timings { public static Timing getTiming(String name) { return getTiming(root, name); } static void reset(); static Timing getTiming(String name); static void print(Timing timing, OutputStream stream); static void printAll(OutputStream stream); static final Timing LIMBO; static boolean on; } | @Test public void testTiming() { Timings.Timing timingName = Timings.getTiming("my.timing.name"); Timings.Timing timingTiming = Timings.getTiming("my.timing"); Timings.Timing timingMy = Timings.getTiming("my"); Timings.Timing root = Timings.getTiming(null); Assert.assertNotNull(timingName); Assert.assertNotNull(timingT... |
CommonFunctions implements SelfReference { public int random(int end) { return rand.nextInt(end); } int random(int end); float random(float end); double random(double end); long random(long end); int random(int start, int end); float random(float start, float end); double random(double start, double end); long random(... | @Test public void testRandoms() throws Exception { for (int i = 0; i < trials; i++) { double value = fn.random(1.0); assertTrue(0.0 <= value && value < 1.0); value = fn.random(0.0, 1.0); assertTrue(0.0 <= value && value < 1.0); value = fn.random(1.0F); assertTrue(0.0 <= value && value < 1.0); value = fn.random(0.0F, 1.... |
CommonFunctions implements SelfReference { public SimpleLocation slocation(String world, int x, int y, int z) { if (world == null) { throw new IllegalArgumentException("world cannot be null"); } return new SimpleLocation(world, x, y, z); } int random(int end); float random(float end); double random(double end); long r... | @Test public void testSLocation() throws Exception { assertEquals(fn.slocation("merp", 1, 2, 3), new SimpleLocation("merp", 1, 2, 3)); } |
CommonFunctions implements SelfReference { public Object newInstance(String className, Object... args) throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalArgumentException, InvocationTargetException { try { Class<?> clazz = Class.forName(className); List<Constructor<?>> validConstructo... | @Test public void testConstructor() throws Exception { ExampleClass e = (ExampleClass) fn.newInstance(example, 1); assertEquals(0, e.marker); e = (ExampleClass) fn.newInstance(example, new Double(1.1)); assertEquals(2, e.marker); File file = null; try { file = (File) fn.newInstance("java.io.File", "test.txt"); FileWrit... |
GsonConfigSource implements IConfigSource { @Override public void reload() { ensureFile(); synchronized (file) { try (Reader fr = this.readerFactory.apply(file)) { synchronized (cache) { cache.clear(); Map<String, Object> loaded = gson.fromJson(fr, new TypeToken<Map<String, Object>>() { }.getType()); if (loaded != null... | @Test public void testReload() { Mockito.when(mockFile.exists()).thenReturn(true); manager.reload(); Map<String, Object> cache = Whitebox.getInternalState(manager, "cache"); List<Integer> list = new ArrayList<>(); list.add(1); list.add(2); list.add(3); Assert.assertEquals(list, cache.get("array")); Assert.assertEquals(... |
GsonConfigSource implements IConfigSource { @Override public void saveAll() { ensureFile(); synchronized (file) { cacheToFile(); } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writerFactory); @Override void reload(); @Override void disable(); @... | @Test public void testSaveAll() { Mockito.when(mockFile.exists()).thenReturn(true); Map<String, Object> cache = Whitebox.getInternalState(manager, "cache"); cache.put("array2", new int[]{4, 5, 6}); cache.put("boolean2", false); cache.put("color2", "#123b9cc"); cache.put("null", null); cache.put("number2", 456); cache.p... |
GsonConfigSource implements IConfigSource { private <T> T get(Map<String, Object> map, String[] path, Class<T> asType) { for (int i = 0; i < path.length; i++) { String key = path[i]; Object value = map.get(key); if (i == path.length - 1) { return asType.cast(value); } else if (value instanceof Map) { map = (Map<String,... | @Test public void testGet() { Mockito.when(mockFile.exists()).thenReturn(true); manager.reload(); Assert.assertTrue(manager.get("object").orElse(null) instanceof Map); Assert.assertEquals("b", manager.get("object.a").orElse(null)); Assert.assertEquals("d", manager.get("object.c").orElse(null)); Assert.assertEquals("f",... |
GsonConfigSource implements IConfigSource { private void put(Map<String, Object> map, String[] path, Object value) { for (int i = 0; i < path.length; i++) { String key = path[i]; if (i == path.length - 1) { map.put(key, value); } else { Object previous = map.computeIfAbsent(key, (k) -> new HashMap<>()); if (!(previous ... | @Test public void testPut() { Mockito.when(mockFile.exists()).thenReturn(true); manager.put("some.data.value", "abc"); manager.put("some.data.value2", 123); manager.put("some.data.value3", false); Assert.assertEquals("abc", manager.get("some.data.value").orElse(null)); Assert.assertEquals(123, manager.get("some.data.va... |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Block block(String world, int x, int y, int z) { return location(world, x, y, z).getBlock(); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Dep... | @Test public void testBlock() { Block mockBlock = Mockito.mock(Block.class); Mockito.when(mockWorld.getBlockAt(Mockito.any(Location.class))) .thenReturn(mockBlock); Assert.assertEquals(mockBlock, fn.block("test", 1, 2, 3)); } |
GsonConfigSource implements IConfigSource { @Override public Set<String> keys() { synchronized (cache) { return new HashSet<>(cache.keySet()); } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writerFactory); @Override void reload(); @Override voi... | @Test public void testKeys() { Mockito.when(mockFile.exists()).thenReturn(true); manager.reload(); Set<String> expected = new HashSet<>(); expected.add("array"); expected.add("boolean"); expected.add("color"); expected.add("null"); expected.add("number"); expected.add("fnumber"); expected.add("object"); expected.add("s... |
GsonConfigSource implements IConfigSource { @Override public boolean isSection(String key) { synchronized (cache) { return get(cache, IConfigSource.toPath(key), Object.class) instanceof Map; } } GsonConfigSource(File file); GsonConfigSource(File file, Function<File, Reader> readerFactory, Function<File, Writer> writer... | @Test public void testIsSection() { Mockito.when(mockFile.exists()).thenReturn(true); manager.reload(); Assert.assertFalse(manager.isSection("array")); Assert.assertFalse(manager.isSection("boolean")); Assert.assertFalse(manager.isSection("color")); Assert.assertFalse(manager.isSection("null")); Assert.assertFalse(mana... |
Lexer { public Token getToken() throws IOException, LexerException { skipWhiteSpaces(); skipComment(); if (Character.isDigit(c)) { return readNumber(); } if (c == '"') { return readString(); } if (c == '`') { return readMultilineString(); } if (isOperator(c)) { return readOperator(); } if (isIdCharacter(c)) { return re... | @Test public void testGetToken() throws Exception { Charset charset = StandardCharsets.UTF_8; String text = "#MESSAGE (1+(4/2.0)/3*4-(2/(3*-4)) >= 0)\n" + "#MESSAGE \"text\" \"test\"\n"; Lexer lexer = new Lexer(text, charset); testToken(lexer, Type.ID, "#MESSAGE"); testToken(lexer, Type.OPERATOR, "("); testToken(lexer,... |
Parser { public Node parse(boolean showWarnings) throws IOException, LexerException, ParserException { this.showWarnings = showWarnings; lexer.setWarnings(showWarnings); Node root = new Node(new Token(Type.ROOT, "<ROOT>", -1, -1)); Node statement = null; while ((statement = parseStatement()) != null) root.getChildren()... | @Test public void testParse() throws IOException, LexerException, ParserException { Charset charset = Charset.forName("UTF-8"); String text = "#MESSAGE (1+(4/2.0)/3*4-(2/(3*-4)) >= 0)\n" + "#MESSAGE \"text\"\n"; Lexer lexer = new Lexer(text, charset); Parser parser = new Parser(lexer); Node root = parser.parse(); Queue... |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public boolean locationEqual(Location loc1, Location loc2) { return loc1.getWorld() == loc2.getWorld() && loc1.getBlockX() == loc2.getBlockX() && loc1.getBlockY() == loc2.getBlockY() && ... | @Test public void testLocationEqual() { Location loc1 = new Location(mockWorld, 1, 2, 3); Location loc2 = new Location(mockWorld, 4, 5, 6, 0.5F, 0.6F); Location loc3 = new Location(mockWorld, 1, 2, 3, 0.7F, 0.8F); Location loc4 = new Location(mockWorld, 4, 5, 6, 0.1F, 0.2F); Assert.assertFalse(fn.locationEqual(loc1, lo... |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public abstract PotionEffect makePotionEffect(String EffectType, int duration, int amplifier, boolean ambient, boolean particles, Color color); AbstractCommonFunctions(TriggerReactorCore... | @Test public abstract void testMakePotionEffect(); |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public Player player(String name) { return Bukkit.getPlayer(name); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstract boolean takeItem... | @Test public void testPlayer() { Assert.assertEquals(mockPlayer, fn.player("wysohn")); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public OfflinePlayer oplayer(String name) { return Bukkit.getOfflinePlayer(name); } AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstract b... | @Test public void testOPlayer() { Assert.assertEquals(mockPlayer, fn.oplayer("wysohn")); } |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public abstract Collection<? extends Player> getPlayers(); AbstractCommonFunctions(TriggerReactorCore plugin); Plugin plugin(String name); @Deprecated abstract boolean takeItem(Player pl... | @Test public abstract void testGetPlayers(); |
AbstractCommonFunctions extends io.github.wysohn.triggerreactor.core.manager.trigger.share.CommonFunctions implements SelfReference { public String currentArea(Entity entity) { String[] areas = currentAreasAt(entity.getLocation()); return areas.length > 0 ? areas[0] : null; } AbstractCommonFunctions(TriggerReactorCore ... | @Test public void testCurrentArea() { } |
MemoryManager { public abstract long acquireExecutionMemory(long numBytes, long taskAttemptId, MemoryMode memoryMode); MemoryManager(SparkConf conf, int numCores, long onHeapStorageMemory, long onHeapExecutionMemory); long pageSizeBytes(); MemoryAllocator tungstenMemoryAllocator(); final void setMemoryStore(MemoryStore... | @Test public void testAcquireExecutionMemory() { MemoryManager memoryManager = createStaticMemoryManager(1000L); TaskMemoryManager taskMemoryManager = new TaskMemoryManager(memoryManager, 0); TestMemoryConsumer consumer = new TestMemoryConsumer(taskMemoryManager); assert taskMemoryManager.acquireExecutionMemory(100L, c... |
SparkContext { public SparkContext(SparkConf conf) { this.conf = conf; this.localProperties = new InheritableThreadLocal<Properties>(){ @Override protected Properties childValue(Properties parentValue) { return SerializationUtils.clone(parentValue); } @Override protected Properties initialValue() { return new Propertie... | @Test public void testSparkContext() { } |
DiskBlockManager { public BlockId[] getAllBlocks() { File[] blockFiles = getAllFiles(); BlockId[] blockIds = new BlockId[blockFiles.length]; for (int i = 0; i < blockFiles.length; ++i) { blockIds[i] = BlockId.apply(blockFiles[i].getName()); } return blockIds; } DiskBlockManager(SparkConf conf, boolean deleteFilesOnStop... | @Test public void testMultiBlocks() { List<BlockId.ShuffleBlockId> blockIs = Lists.newLinkedList(); for (int i = 0; i < 100; ++i) { blockIs.add(new BlockId.ShuffleBlockId(1, i, 0)); } List<File> shuffleFiles = blockIs.stream().map(diskBlockManager::getFile).collect(Collectors.toList()); shuffleFiles.forEach(file -> wri... |
LineChart extends AbstractLineChart { public final void setSparkline(final boolean isSparkline) { this.isSparkline = isSparkline; } LineChart(final ImmutableList<? extends Plot> lines); final void setSparkline(final boolean isSparkline); } | @Test public void test4() { final Line line = Plots.newLine(Data.newData(0, 50, 100), GREEN); final LineChart chart = GCharts.newLineChart(line); chart.setSparkline(true); chart.setTitle("Foobar"); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString()); String expectedString = "http: assertEquals("Junit ... |
Data { @Override public String toString() { return Arrays.toString(data); } Data(final double... data); @Override String toString(); final double[] getData(); final int getSize(); static Data newData(final double... data); static Data newData(final List<? extends Number> data); static final double MIN_VALUE; static fin... | @Test public void testData1() { Data data = new Data(-1, 0, 100); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(data.toString()); assertEquals("Junit error", "[-1.0, 0.0, 100.0]", data.toString()); } |
AxisStyle implements Kloneable<AxisStyle> { public static AxisStyle newAxisStyle(final Color textColor, final int fontSize, final AxisTextAlignment alignment) { checkNotNull(textColor, "color must not be null"); checkArgument(fontSize > 0, "fontsize must be > 0"); checkNotNull(alignment, "alignment must not be null"); ... | @Test public void testAxisAlignment() { final LineChart chart = TestUtil.getBasicChart(); chart.setGrid(50, 50, 5, 0); AxisStyle axisStyle = AxisStyle.newAxisStyle(RED, 16, AxisTextAlignment.LEFT); AxisLabels axisLabels = AxisLabelsFactory.newAxisLabels("Foo", 50); axisLabels.setAxisStyle(axisStyle); chart.addXAxisLabe... |
AbstractAxisChart extends AbstractGraphChart implements GridChart { public final void setGrid(final double xAxisStepSize, final double yAxisStepSize, final int lengthOfLineSegment, final int lengthOfBlankSegment) { checkArgument(xAxisStepSize > 0, "xAxisStepSize must be positive: %s", xAxisStepSize); checkArgument(yAxi... | @Test public void testSetGrid0() { try { final LineChart chart = getBasicChart(); chart.setGrid(0, 0, 0, 0); } catch (IllegalArgumentException e) { return; } fail(); }
@Test public void testSetGrid1() { final LineChart chart = getBasicChart(); chart.setGrid(10, 10, 1, 0); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).inf... |
AbstractAxisChart extends AbstractGraphChart implements GridChart { public final void addXAxisLabels(final AxisLabels axisLabels) { checkNotNull(axisLabels, "axisLabel cannnot be null"); xAxisLabels.add((AxisLabelsImpl) axisLabels.klone()); } AbstractAxisChart(); final void addXAxisLabels(final AxisLabels axisLabels); ... | @Test public void testXAxisLabels0() { final LineChart chart = getBasicChart(); chart.addXAxisLabels(AxisLabelsFactory.newAxisLabels("start", "end")); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString()); String expectedString = "http: assertEquals("Junit error", normalize(expectedString), normalize(ch... |
AbstractAxisChart extends AbstractGraphChart implements GridChart { public final void addYAxisLabels(final AxisLabels axisLabels) { checkNotNull(axisLabels, "axisLabel cannnot be null"); yAxisLabels.add((AxisLabelsImpl) axisLabels.klone()); } AbstractAxisChart(); final void addXAxisLabels(final AxisLabels axisLabels); ... | @Test public void testYAxisLabels() { final LineChart chart = getBasicChart(); chart.addYAxisLabels(AxisLabelsFactory.newAxisLabels("start", "end")); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString()); String expectedString = "http: assertEquals("Junit error", normalize(expectedString), normalize(cha... |
AbstractAxisChart extends AbstractGraphChart implements GridChart { public final void addTopAxisLabels(final AxisLabels axisLabels) { checkNotNull(axisLabels, "axisLabel cannnot be null"); topAxisLabels.add((AxisLabelsImpl) axisLabels.klone()); } AbstractAxisChart(); final void addXAxisLabels(final AxisLabels axisLabel... | @Test public void testTopAxisLabels() { final LineChart chart = getBasicChart(); chart.addTopAxisLabels(AxisLabelsFactory.newAxisLabels("start", "end")); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString()); String expectedString = "http: assertEquals("Junit error", normalize(expectedString), normalize... |
AbstractAxisChart extends AbstractGraphChart implements GridChart { public final void addRightAxisLabels(final AxisLabels axisLabels) { checkNotNull(axisLabels, "axisLabels cannnot be null"); rightAxisLabels.add((AxisLabelsImpl) axisLabels.klone()); } AbstractAxisChart(); final void addXAxisLabels(final AxisLabels axis... | @Test public void testRightAxisLabels() { final LineChart chart = getBasicChart(); chart.addRightAxisLabels(AxisLabelsFactory.newAxisLabels("start", "end")); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString()); String expectedString = "http: assertEquals("Junit error", normalize(expectedString), norma... |
AbstractAxisChart extends AbstractGraphChart implements GridChart { public final void addMarker(final Marker marker, final double xPos, final double yPos) { checkNotNull(marker, "marker cannnot be null"); checkArgument(xPos >= 0 && xPos <= 100, "xPos must be >= 0 and <= 100: %s", xPos); checkArgument(yPos >= 0 && yPos ... | @Test public void addFreeShapeMarkersToBarChart() { final BarChart chart = getBasicBarChart(); chart.addMarker(Markers.newShapeMarker(Shape.ARROW, RED, 12,Priority.LOW), 50, 80); chart.addMarker(Markers.newShapeMarker(Shape.X, BLUE, 12,Priority.HIGH), 50, 80); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toUR... |
UrlUtil { public static String normalize(final String s) { if (s == null) { return ""; } final ImmutableList<String> stringList = Lists.of(s.split("\\?")); if (stringList.size() != 2) { return s; } final String args = stringList.get(1); final List<String> params = Arrays.asList(args.split("&")); Collections.sort(params... | @Test public void testNormalize() { final String unnormalizedString = "http: final String expectedString = "http: assertEquals("Junit error", normalize(expectedString), UrlUtil.normalize(unnormalizedString)); } |
LineStyle { public static LineStyle newLineStyle(final int lineThickness, final int lengthOfLineSegment, final int lengthOfBlankSegment) { checkArgument(lineThickness > 0, "line thickness must be > 0: %s", lineThickness); checkArgument(lengthOfLineSegment >= 0, "length of line segment must be >= 0: %s", lengthOfLineSeg... | @Test public void testNewLineStyle0() { try { final Line line = TestUtil.getBasicLine(); line.setLineStyle(LineStyle.newLineStyle(0, 0, 0)); } catch (IllegalArgumentException e) { return; } fail(); } |
GCharts { public static LineChart newLineChart(final Line... plots) { checkNotNull(plots, "plots cannot be null or contain a null."); checkContentsNotNull(Arrays.asList(plots), "plots cannot be null or contain a null."); return new LineChart(Plots.copyOf(plots)); } private GCharts(); static LineChart newLineChart(fina... | @Test public void testNewLineChart0() { try { Line[] lines = null; GCharts.newLineChart(lines); } catch (NullPointerException e) { return; } }
@Test public void testNewLineChart1() { try { Line[] lines = { TestUtil.getBasicLine(), null }; GCharts.newLineChart(lines); } catch (NullPointerException e) { return; } } |
PieChart extends AbstractGraphChart { public final void setThreeD(final boolean threeD) { this.threeD = threeD; } PieChart(final ImmutableList<? extends Slice> slices); void setOrientation(final double radians); final boolean isThreeD(); final void setThreeD(final boolean threeD); } | @Test public void basicTest() { final Slice s1 = Slice.newSlice(45, GRAY, "Safari", "X"); final Slice s2 = Slice.newSlice(45, ORANGERED, "Firefox", "Y"); final Slice s3 = Slice.newSlice(10, BLUE, "Internet Explorer", "Z"); PieChart chart = GCharts.newPieChart(s1, s2, s3); chart.setTitle("A Better World 1"); chart.setSi... |
PieChart extends AbstractGraphChart { public void setOrientation(final double radians) { this.orientation = radians; } PieChart(final ImmutableList<? extends Slice> slices); void setOrientation(final double radians); final boolean isThreeD(); final void setThreeD(final boolean threeD); } | @Test public void orientationTest() { final Slice s1 = Slice.newSlice(450, "Safari"); final Slice s2 = Slice.newSlice(450, "Firefox"); final Slice s3 = Slice.newSlice(100, "Internet Explorer"); PieChart chart = GCharts.newPieChart(s1, s2, s3); chart.setOrientation(3.14/2); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).in... |
AbstractMarkableChart extends AbstractAxisChart { public final void addHorizontalRangeMarker(final double startPoint, final double endPoint, final Color color) { checkRangeArgs(startPoint, endPoint); checkNotNull(color, "Color cannot be null."); horizontalRangeMarkers.add(new HorizontalRangeMarker(color, startPoint, en... | @Test public void testAddVerticalRangeMarker0() { try { final LineChart chart = getBasicChart(); chart.addHorizontalRangeMarker(100, 200, RED); } catch (IllegalArgumentException e) { return; } fail(); }
@Test public void testAddVerticalRangeMarker1() { final LineChart chart = getBasicChart(); chart.addHorizontalRangeMa... |
AbstractGraphChart extends AbstractGChart implements GraphChart, TitledChart { public final void setTitle(final String title) { checkNotNull(title, "Title cannot be null."); this.chartTitle = new ChartTitle(title); } AbstractGraphChart(); final void setTitle(final String title); final void setTitle(final String title, ... | @Test public void testSetTitleString0() { try { final LineChart chart = getBasicChart(); chart.setTitle(null); } catch (NullPointerException e) { return; } fail(); }
@Test public void testSetTitleString1() { final LineChart chart = getBasicChart(); chart.setTitle("foo"); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info... |
AbstractMarkableChart extends AbstractAxisChart { public final void addVerticalRangeMarker(final double startPoint, final double endPoint, final Color color) { checkRangeArgs(startPoint, endPoint); checkNotNull(color, "Color cannot be null."); verticalRangeMarkers.add(new VerticalRangeMarker(color, startPoint, endPoint... | @Test public void testAddHorizontalRangeMarker0() { try { final LineChart chart = getBasicChart(); chart.addVerticalRangeMarker(100, 200, RED); } catch (IllegalArgumentException e) { return; } fail(); }
@Test public void testAddHorizontalRangeMarker1() { final LineChart chart = getBasicChart(); chart.addVerticalRangeMa... |
MapChart extends AbstractGChart { public final void addPoliticalBoundaries(final PoliticalBoundary... politicalBoundaries) { pBoundaries.addAll(Lists.of(politicalBoundaries)); } MapChart(final GeographicalArea geographicalArea); final void setColorGradient(final Color defaultColor, final Color... colorGradient); final ... | @Test public void test() { MapChart chart = GCharts.newMapChart(GeographicalArea.AFRICA); chart.addPoliticalBoundaries(new Country(MADAGASCAR, 90)); chart.addPoliticalBoundaries(new Country(MOROCCO, 10)); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(chart.toURLString()); String expectedString = "http: assertEquals(... |
DataUtil { public static Data scaleWithinRange(final double min, final double max, final double[] data) { checkArgument(max - min > 0, "min >= max!"); return Data.newData(privateScale(data, min, max)); } private DataUtil(); static Data scaleWithinRange(final double min, final double max, final double[] data); static D... | @Test public void testScaleData0() { Data data = DataUtil.scaleWithinRange(0, 10, new double[] { 1, 2, 3, 4, 5, 6 }); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(data.toString()); assertEquals("Junit error", "[10.0, 20.0, 30.0, 40.0, 50.0, 60.0]", data.toString()); }
@Test public void testScaleData3() { Data data ... |
DataUtil { public static Data scale(final double... data) { checkNotNull(data, "data is null or contents of data is null."); final double min = Collections.min(PrimitiveArrays.asList(data)); final double max = Collections.max(PrimitiveArrays.asList(data)); checkArgument(min < max, "Cannot scale this data. It is ill con... | @Test public void testScaleData1() { Data data = DataUtil.scale(1, 2, 3, 4, 5, 6); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(data.toString()); assertEquals("Junit error", "[0.0, 20.0, 40.0, 60.0, 80.0, 100.0]", data.toString()); }
@Test public void testScaleData2() { Data data = DataUtil.scale(-10, 1, 2, 3, 4, 5... |
DataUtil { public static List<Data> scaleDataList(final List<? extends List<? extends Number>> data) { checkContentsNotNull(data, "data is null or contents of data is null."); final double[][] d = new double[data.size()][]; int j = 0; for (List<? extends Number> datum : data) { checkContentsNotNull(datum, "data is null... | @Test public void testScaleData5() { double d0[] = new double[] { 4, 5, 6 }; double d1[] = new double[] { 0, 5, 10 }; List<Double> l0 = PrimitiveArrays.asList(d0); List<Double> l1 = PrimitiveArrays.asList(d1); List<List<Double>> d = new LinkedList<List<Double>>(); d.add(l0); d.add(l1); List<Data> data = DataUtil.scaleD... |
DataParameter extends AbstractParameter { void addData(final Data data) { datas.add(data); } DataParameter(); @Override String getKey(); @Override String getValue(); } | @Test public void test0() { final Data data = new Data(1, 2, 3); final DataParameter p = new DataParameter(); p.addData(data); Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).info(p.toURLParameterString()); final String expectedString = "chd=e:ApBSB7"; assertEquals("Junit error", expectedString, p.toURLParameterString()); ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.