method2testcases stringlengths 118 3.08k |
|---|
### Question:
StringArray { public static String[] valueOf(String str) { return str.split("\\s*,\\s*"); } private StringArray(); static String[] valueOf(String str); }### Answer:
@Test public void testValueOf() { String[] ary = StringArray.valueOf("a,b"); assertThat(ary, arrayContaining("a", "b")); } |
### Question:
CharsetConverter implements IStringConverter<Charset> { public Charset convert(String value) { try { return Charset.forName(value); } catch (IllegalCharsetNameException e) { throw new ParameterException("unknown encoding '" + value + "'"); } catch (UnsupportedCharsetException e) { throw new ParameterExcep... |
### Question:
Main { private void version() { if (lint == null) { lint = lintBuilder.fromDefault(); } info("using jslint version " + lint.getEdition()); throw new DieException(null, 0); } static void main(String[] args); }### Answer:
@Test public void testVersion() throws Exception { kaboom.expect(DieException.class)... |
### Question:
JSFunction { @Override public String toString() { return String.format("function %s()", getName()); } private JSFunction(Builder builder); List<String> getClosure(); List<String> getException(); List<String> getGlobal(); List<String> getLabel(); int getLast(); int getLine(); String getName(); List<String... |
### Question:
ConditionEvents implements Iterable<ConditionEvent> { @PublicAPI(usage = ACCESS) public boolean isEmpty() { return getAllowed().isEmpty() && getViolating().isEmpty(); } @PublicAPI(usage = ACCESS) ConditionEvents(); @PublicAPI(usage = ACCESS) void add(ConditionEvent event); @PublicAPI(usage = ACCESS) void... |
### Question:
ContainAnyCondition extends ArchCondition<Collection<? extends T>> { @Override public void check(Collection<? extends T> collection, ConditionEvents events) { ConditionEvents subEvents = new ConditionEvents(); for (T element : collection) { condition.check(element, subEvents); } if (!subEvents.isEmpty()) ... |
### Question:
AccessTarget implements HasName.AndFullName, CanBeAnnotated, HasOwner<JavaClass> { @Override @PublicAPI(usage = ACCESS) public JavaClass getOwner() { return owner; } AccessTarget(JavaClass owner, String name, String fullName); @Override @PublicAPI(usage = ACCESS) String getName(); @Override @PublicAPI(usa... |
### Question:
ThrowsClause implements HasOwner<LOCATION>, Iterable<ThrowsDeclaration<LOCATION>> { @PublicAPI(usage = ACCESS) public boolean containsType(Class<?> type) { return containsType(type.getName()); } private ThrowsClause(LOCATION location, List<JavaClass> thrownTypes); @PublicAPI(usage = ACCESS) boolean conta... |
### Question:
ThrowsClause implements HasOwner<LOCATION>, Iterable<ThrowsDeclaration<LOCATION>> { @PublicAPI(usage = ACCESS) public int size() { return throwsDeclarations.size(); } private ThrowsClause(LOCATION location, List<JavaClass> thrownTypes); @PublicAPI(usage = ACCESS) boolean containsType(Class<?> type); @Pub... |
### Question:
ThrowsClause implements HasOwner<LOCATION>, Iterable<ThrowsDeclaration<LOCATION>> { @PublicAPI(usage = ACCESS) public JavaClassList getTypes() { return new JavaClassList(FluentIterable.from(throwsDeclarations).transform(toGuava(GET_RAW_TYPE)).toList()); } private ThrowsClause(LOCATION location, List<Java... |
### Question:
JavaClasses extends ForwardingCollection<JavaClass> implements DescribedIterable<JavaClass>, CanOverrideDescription<JavaClasses> { @PublicAPI(usage = ACCESS) public JavaClasses that(DescribedPredicate<? super JavaClass> predicate) { Map<String, JavaClass> matchingElements = Guava.Maps.filterValues(classes... |
### Question:
JavaClasses extends ForwardingCollection<JavaClass> implements DescribedIterable<JavaClass>, CanOverrideDescription<JavaClasses> { @PublicAPI(usage = ACCESS) public boolean contain(Class<?> reflectedType) { return contain(reflectedType.getName()); } private JavaClasses(JavaPackage defaultPackage, Map<Str... |
### Question:
JavaClasses extends ForwardingCollection<JavaClass> implements DescribedIterable<JavaClass>, CanOverrideDescription<JavaClasses> { @PublicAPI(usage = ACCESS) public JavaClass get(Class<?> reflectedType) { return get(reflectedType.getName()); } private JavaClasses(JavaPackage defaultPackage, Map<String, J... |
### Question:
JavaClasses extends ForwardingCollection<JavaClass> implements DescribedIterable<JavaClass>, CanOverrideDescription<JavaClasses> { static JavaClasses of(Iterable<JavaClass> classes) { Map<String, JavaClass> mapping = new HashMap<>(); for (JavaClass clazz : classes) { mapping.put(clazz.getName(), clazz); }... |
### Question:
Source { @PublicAPI(usage = ACCESS) public Optional<String> getFileName() { return fileName; } Source(URI uri, Optional<String> fileName, boolean md5InClassSourcesEnabled); @PublicAPI(usage = ACCESS) URI getUri(); @PublicAPI(usage = ACCESS) Optional<String> getFileName(); @PublicAPI(usage = ACCESS) Md5sum... |
### Question:
Source { @Override public int hashCode() { return Objects.hash(uri, md5sum); } Source(URI uri, Optional<String> fileName, boolean md5InClassSourcesEnabled); @PublicAPI(usage = ACCESS) URI getUri(); @PublicAPI(usage = ACCESS) Optional<String> getFileName(); @PublicAPI(usage = ACCESS) Md5sum getMd5sum(); @O... |
### Question:
Source { @PublicAPI(usage = ACCESS) public Md5sum getMd5sum() { return md5sum; } Source(URI uri, Optional<String> fileName, boolean md5InClassSourcesEnabled); @PublicAPI(usage = ACCESS) URI getUri(); @PublicAPI(usage = ACCESS) Optional<String> getFileName(); @PublicAPI(usage = ACCESS) Md5sum getMd5sum(); ... |
### Question:
Dependency implements HasDescription, Comparable<Dependency>, HasSourceCodeLocation { @Override @PublicAPI(usage = ACCESS) public String getDescription() { return description; } private Dependency(JavaClass originClass, JavaClass targetClass, int lineNumber, String description); @PublicAPI(usage = ACCESS... |
### Question:
Dependency implements HasDescription, Comparable<Dependency>, HasSourceCodeLocation { static Optional<Dependency> tryCreateFromInstanceofCheck(InstanceofCheck instanceofCheck) { return tryCreateDependencyFromJavaMemberWithLocation(instanceofCheck.getOwner(), "checks instanceof", instanceofCheck.getRawType... |
### Question:
Dependency implements HasDescription, Comparable<Dependency>, HasSourceCodeLocation { private Dependency(JavaClass originClass, JavaClass targetClass, int lineNumber, String description) { this.originClass = originClass; this.targetClass = targetClass; this.lineNumber = lineNumber; this.description = desc... |
### Question:
Transformers { static ClassesTransformer<JavaClass> classes() { return new AbstractClassesTransformer<JavaClass>("classes") { @Override public Iterable<JavaClass> doTransform(JavaClasses collection) { return collection; } }; } }### Answer:
@Test public void test_classes() { JavaClasses input = importCl... |
### Question:
JavaTypeVariable implements JavaType, HasUpperBounds { @Override @PublicAPI(usage = ACCESS) public String getName() { return name; } JavaTypeVariable(String name, JavaClass erasure); @Override @PublicAPI(usage = ACCESS) String getName(); @PublicAPI(usage = ACCESS) List<JavaType> getBounds(); @Override @Pu... |
### Question:
JavaTypeVariable implements JavaType, HasUpperBounds { @Override public String toString() { String bounds = printExtendsClause() ? " extends " + joinTypeNames(upperBounds) : ""; return getClass().getSimpleName() + '{' + getName() + bounds + '}'; } JavaTypeVariable(String name, JavaClass erasure); @Overrid... |
### Question:
AbstractClassesTransformer implements ClassesTransformer<T> { @Override public final DescribedIterable<T> transform(JavaClasses collection) { return DescribedIterable.From.iterable(doTransform(collection), description); } protected AbstractClassesTransformer(String description); @Override final Described... |
### Question:
PluginLoader { public T load() { return supplier.get(); } private PluginLoader(Class<T> pluginType, Map<JavaVersion, String> versionToPlugins, T fallback); static Creator<T> forType(Class<T> pluginType); T load(); }### Answer:
@Test public void loads_correct_plugin_for_version() { System.setProperty("ja... |
### Question:
DescribedPredicate implements Predicate<T> { @SuppressWarnings("unchecked") public static <T> DescribedPredicate<T> alwaysTrue() { return (DescribedPredicate<T>) ALWAYS_TRUE; } DescribedPredicate(String description, Object... params); String getDescription(); DescribedPredicate<T> as(String description, O... |
### Question:
DescribedPredicate implements Predicate<T> { @SuppressWarnings("unchecked") public static <T> DescribedPredicate<T> alwaysFalse() { return (DescribedPredicate<T>) ALWAYS_FALSE; } DescribedPredicate(String description, Object... params); String getDescription(); DescribedPredicate<T> as(String description,... |
### Question:
DescribedPredicate implements Predicate<T> { public static DescribedPredicate<Iterable<?>> empty() { return new EmptyPredicate(); } DescribedPredicate(String description, Object... params); String getDescription(); DescribedPredicate<T> as(String description, Object... params); DescribedPredicate<T> and(f... |
### Question:
PackageMatcher { @PublicAPI(usage = ACCESS) public static PackageMatcher of(String packageIdentifier) { return new PackageMatcher(packageIdentifier); } private PackageMatcher(String packageIdentifier); @PublicAPI(usage = ACCESS) static PackageMatcher of(String packageIdentifier); @PublicAPI(usage = ACCES... |
### Question:
PackageMatchers extends DescribedPredicate<String> { @PublicAPI(usage = ACCESS) public static PackageMatchers of(String... packageIdentifiers) { return of(ImmutableSet.copyOf(packageIdentifiers)); } private PackageMatchers(Set<String> packageIdentifiers); @PublicAPI(usage = ACCESS) static PackageMatchers... |
### Question:
ChainableFunction implements Function<F, T> { public <E> ChainableFunction<E, T> after(final Function<? super E, ? extends F> function) { return new ChainableFunction<E, T>() { @Override public T apply(E input) { return ChainableFunction.this.apply(function.apply(input)); } }; } ChainableFunction<E, T> a... |
### Question:
ChainableFunction implements Function<F, T> { public <U> ChainableFunction<F, U> then(final Function<? super T, ? extends U> function) { return new ChainableFunction<F, U>() { @Override public U apply(F input) { return function.apply(ChainableFunction.this.apply(input)); } }; } ChainableFunction<E, T> af... |
### Question:
ChainableFunction implements Function<F, T> { public DescribedPredicate<F> is(DescribedPredicate<? super T> predicate) { return predicate.onResultOf(this); } ChainableFunction<E, T> after(final Function<? super E, ? extends F> function); ChainableFunction<F, U> then(final Function<? super T, ? extends U>... |
### Question:
Cycle { List<Edge<T, ATTACHMENT>> getEdges() { return path.getEdges(); } Cycle(List<Edge<T, ATTACHMENT>> edges); Cycle(Path<T, ATTACHMENT> path); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static Cycle<T, ATTACHMENT> from(Path<T, ATTACHMENT> path); }###... |
### Question:
SliceIdentifier { @PublicAPI(usage = ACCESS) public static SliceIdentifier of(String... parts) { return of(ImmutableList.copyOf(parts)); } private SliceIdentifier(List<String> parts); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @PublicAPI(usage = ACCESS) s... |
### Question:
Slice extends ForwardingSet<JavaClass> implements HasDescription, CanOverrideDescription<Slice> { @PublicAPI(usage = ACCESS) public Set<Dependency> getDependenciesFromSelf() { ImmutableSet.Builder<Dependency> result = ImmutableSet.builder(); for (JavaClass javaClass : this) { for (Dependency dependency : ... |
### Question:
Slice extends ForwardingSet<JavaClass> implements HasDescription, CanOverrideDescription<Slice> { @PublicAPI(usage = ACCESS) public Set<Dependency> getDependenciesToSelf() { ImmutableSet.Builder<Dependency> result = ImmutableSet.builder(); for (JavaClass javaClass : this) { for (Dependency dependency : ja... |
### Question:
Edge { @Override public int hashCode() { return hashCode; } Edge(T from, T to, Collection<ATTACHMENT> attachments); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }### Answer:
@Test public void hashCode_of_two_equal_edges_is_equal() { Edge<Object, Object> equ... |
### Question:
JavaClassDiagramAssociation { Set<String> getPackageIdentifiersFromComponentOf(JavaClass javaClass) { return getPackageIdentifiersFromComponentOf(getComponentOf(javaClass)); } JavaClassDiagramAssociation(PlantUmlDiagram diagram); }### Answer:
@Test public void get_package_identifier_associated_with_clas... |
### Question:
JavaClassDiagramAssociation { boolean contains(JavaClass javaClass) { return !getAssociatedComponents(javaClass).isEmpty(); } JavaClassDiagramAssociation(PlantUmlDiagram diagram); }### Answer:
@Test public void reports_if_class_is_contained_in_any_component() { JavaClassDiagramAssociation javaClassDiagr... |
### Question:
FreezingArchRule implements ArchRule { @PublicAPI(usage = ACCESS) public static FreezingArchRule freeze(ArchRule rule) { return new FreezingArchRule(rule, ViolationStoreFactory.create(), ViolationLineMatcherFactory.create()); } private FreezingArchRule(ArchRule delegate, ViolationStore store, ViolationLi... |
### Question:
ViolationLineMatcherFactory { static ViolationLineMatcher create() { return ArchConfiguration.get().containsProperty(FREEZE_LINE_MATCHER_PROPERTY) ? createInstance(ArchConfiguration.get().getProperty(FREEZE_LINE_MATCHER_PROPERTY)) : DEFAULT_MATCHER; } }### Answer:
@Test @DataProvider(splitBy = "\\|", v... |
### Question:
ReflectionUtils { static Collection<Field> getAllFields(Class<?> owner, Predicate<? super Field> predicate) { return filter(getAll(owner, new Collector<Field>() { @Override protected Collection<? extends Field> extractFrom(Class<?> type) { return ImmutableList.copyOf(type.getDeclaredFields()); } }), toGua... |
### Question:
ReflectionUtils { static Collection<Method> getAllMethods(Class<?> owner, Predicate<? super Method> predicate) { return filter(getAll(owner, new Collector<Method>() { @Override protected Collection<? extends Method> extractFrom(Class<?> type) { return ImmutableList.copyOf(type.getDeclaredMethods()); } }),... |
### Question:
ReflectionUtils { static Set<Class<?>> getAllSuperTypes(Class<?> type) { if (type == null) { return Collections.emptySet(); } ImmutableSet.Builder<Class<?>> result = ImmutableSet.<Class<?>>builder() .add(type) .addAll(getAllSuperTypes(type.getSuperclass())); for (Class<?> c : type.getInterfaces()) { resul... |
### Question:
ArchCondition { public void init(Iterable<T> allObjectsToTest) { } ArchCondition(String description, Object... args); void init(Iterable<T> allObjectsToTest); abstract void check(T item, ConditionEvents events); void finish(ConditionEvents events); ArchCondition<T> and(ArchCondition<? super T> condition);... |
### Question:
ArchCondition { public void finish(ConditionEvents events) { } ArchCondition(String description, Object... args); void init(Iterable<T> allObjectsToTest); abstract void check(T item, ConditionEvents events); void finish(ConditionEvents events); ArchCondition<T> and(ArchCondition<? super T> condition); Arc... |
### Question:
EvaluationResult { @PublicAPI(usage = ACCESS) public FailureReport getFailureReport() { return new FailureReport(rule, priority, events.getFailureMessages()); } @PublicAPI(usage = ACCESS) EvaluationResult(HasDescription rule, Priority priority); @PublicAPI(usage = ACCESS) EvaluationResult(HasDescription... |
### Question:
InitialConfiguration { public synchronized void set(T object) { checkState(this.value == null, String.format( "Configuration may only be set once - current: %s / new: %s", this.value, object)); this.value = object; } synchronized void set(T object); synchronized T get(); }### Answer:
@Test public void t... |
### Question:
InitialConfiguration { public synchronized T get() { checkState(value != null, "No value was ever set"); return value; } synchronized void set(T object); synchronized T get(); }### Answer:
@Test public void throws_exception_if_no_value_is_present_on_access() { thrown.expect(IllegalStateException.class);... |
### Question:
Locations { @PublicAPI(usage = ACCESS) public static Set<Location> of(Iterable<URL> urls) { ImmutableSet.Builder<Location> result = ImmutableSet.builder(); for (URL url : urls) { result.add(Location.of(url)); } return result.build(); } private Locations(); @PublicAPI(usage = ACCESS) static Set<Location> ... |
### Question:
Locations { @PublicAPI(usage = ACCESS) public static Set<Location> ofClass(Class<?> clazz) { return getLocationsOf(asResourceName(clazz.getName()) + ".class"); } private Locations(); @PublicAPI(usage = ACCESS) static Set<Location> of(Iterable<URL> urls); @PublicAPI(usage = ACCESS) static Set<Location> of... |
### Question:
Locations { @PublicAPI(usage = ACCESS) public static Set<Location> inClassPath() { ImmutableSet.Builder<Location> result = ImmutableSet.builder(); for (URL url : locationResolver.get().resolveClassPath()) { result.add(Location.of(url)); } return result.build(); } private Locations(); @PublicAPI(usage = A... |
### Question:
Location { @PublicAPI(usage = ACCESS) public boolean contains(String part) { return uri.toString().contains(part); } Location(NormalizedUri uri); @PublicAPI(usage = ACCESS) URI asURI(); @PublicAPI(usage = ACCESS) boolean contains(String part); @PublicAPI(usage = ACCESS) boolean matches(Pattern pattern); @... |
### Question:
Location { @PublicAPI(usage = ACCESS) public boolean matches(Pattern pattern) { return pattern.matcher(uri.toString()).matches(); } Location(NormalizedUri uri); @PublicAPI(usage = ACCESS) URI asURI(); @PublicAPI(usage = ACCESS) boolean contains(String part); @PublicAPI(usage = ACCESS) boolean matches(Patt... |
### Question:
Location { @PublicAPI(usage = ACCESS) public URI asURI() { return uri.toURI(); } Location(NormalizedUri uri); @PublicAPI(usage = ACCESS) URI asURI(); @PublicAPI(usage = ACCESS) boolean contains(String part); @PublicAPI(usage = ACCESS) boolean matches(Pattern pattern); @PublicAPI(usage = ACCESS) abstract b... |
### Question:
Location { Location append(String relativeURI) { relativeURI = encodeIllegalCharacters(relativeURI); if (uri.toString().endsWith("/") && relativeURI.startsWith("/")) { relativeURI = relativeURI.substring(1); } if (!uri.toString().endsWith("/") && !relativeURI.startsWith("/")) { relativeURI = "/" + relativ... |
### Question:
ContainsOnlyCondition extends ArchCondition<Collection<? extends T>> { @Override public void check(Collection<? extends T> collection, ConditionEvents events) { ConditionEvents subEvents = new ConditionEvents(); for (T item : collection) { condition.check(item, subEvents); } if (!subEvents.isEmpty()) { ev... |
### Question:
JavaClassDescriptorImporter { static JavaClassDescriptor createFromAsmObjectTypeName(String objectTypeName) { return importAsmType(Type.getObjectType(objectTypeName)); } }### Answer:
@Test public void asm_object_type() { JavaClassDescriptor objectType = JavaClassDescriptorImporter.createFromAsmObjectTy... |
### Question:
JavaClassDescriptorImporter { static JavaClassDescriptor importAsmType(Type type) { return JavaClassDescriptor.From.name(type.getClassName()); } }### Answer:
@Test public void asm_Type() throws NoSuchMethodException { Type toStringType = Type.getReturnType(Object.class.getDeclaredMethod("toString")); J... |
### Question:
JavaAccess implements HasName, HasDescription, HasOwner<JavaCodeUnit>, HasSourceCodeLocation { @Override @PublicAPI(usage = ACCESS) public String getDescription() { String description = origin.getDescription() + " " + descriptionVerb() + " " + getTarget().getDescription(); return description + " in " + ge... |
### Question:
Formatters { @PublicAPI(usage = ACCESS) public static String ensureSimpleName(String name) { int lastIndexOfDot = name.lastIndexOf('.'); String partAfterDot = lastIndexOfDot >= 0 ? name.substring(lastIndexOfDot + 1) : name; int lastIndexOf$ = partAfterDot.lastIndexOf('$'); String simpleNameCandidate = las... |
### Question:
NeverCondition extends ArchCondition<T> { @Override public void init(Iterable<T> allObjectsToTest) { condition.init(allObjectsToTest); } NeverCondition(ArchCondition<T> condition); @Override void init(Iterable<T> allObjectsToTest); @Override void finish(ConditionEvents events); @Override void check(T item... |
### Question:
JavaFieldAccess extends JavaAccess<FieldAccessTarget> { @Override public int hashCode() { return 31 * super.hashCode() + accessType.hashCode(); } JavaFieldAccess(JavaFieldAccessBuilder builder); @PublicAPI(usage = ACCESS) AccessType getAccessType(); @Override int hashCode(); @Override boolean equals(Objec... |
### Question:
AnnotationProxy { public static <A extends Annotation> A of(Class<A> annotationType, JavaAnnotation<?> toProxy) { checkArgument(annotationType.getName().equals(toProxy.getRawType().getName()), "Requested annotation type %s is incompatible with %s of type %s", annotationType.getSimpleName(), JavaAnnotation... |
### Question:
JavaWildcardType implements JavaType, HasUpperBounds { @Override @PublicAPI(usage = ACCESS) public String getName() { return WILDCARD_TYPE_NAME; } JavaWildcardType(JavaWildcardTypeBuilder builder); @Override @PublicAPI(usage = ACCESS) String getName(); @Override @PublicAPI(usage = ACCESS) List<JavaType> g... |
### Question:
JavaWildcardType implements JavaType, HasUpperBounds { @Override @PublicAPI(usage = ACCESS) public List<JavaType> getUpperBounds() { return upperBounds; } JavaWildcardType(JavaWildcardTypeBuilder builder); @Override @PublicAPI(usage = ACCESS) String getName(); @Override @PublicAPI(usage = ACCESS) List<Jav... |
### Question:
JavaWildcardType implements JavaType, HasUpperBounds { @PublicAPI(usage = ACCESS) public List<JavaType> getLowerBounds() { return lowerBounds; } JavaWildcardType(JavaWildcardTypeBuilder builder); @Override @PublicAPI(usage = ACCESS) String getName(); @Override @PublicAPI(usage = ACCESS) List<JavaType> get... |
### Question:
JavaWildcardType implements JavaType, HasUpperBounds { @Override public String toString() { String bounds = boundsToString(); return getClass().getSimpleName() + '{' + getName() + bounds + '}'; } JavaWildcardType(JavaWildcardTypeBuilder builder); @Override @PublicAPI(usage = ACCESS) String getName(); @Ove... |
### Question:
QuickSort extends AbstractSort<E> { public void sort(SortableCollection<E> sortable) { int n = sortable.size(); FJQuickSort<E> qsort = new FJQuickSort<>(comparator,swapper); qsort.qsort(sortable, 0, n-1); } void sort(SortableCollection<E> sortable); }### Answer:
@Test public void canSortStrings() { fina... |
### Question:
ResourceBasedProductLookup implements ProductLookup { @Override public List<String> byQuery(String query) { log.info("query is {}", query); loadProducts(); List<String> pis = new LinkedList<>(); StringTokenizer st = new StringTokenizer(query, "&="); while (st.hasMoreTokens()) { final String key = st.nextT... |
### Question:
UniqueGuesser extends Guesser { @Override protected Guess nextGuess() { Guess guess = super.nextGuess(); while (guess.isNotUnique()) { guess = super.nextGuess(); } return guess; } @Inject UniqueGuesser(Table table); }### Answer:
@Test public void generateAllGuesses() { int numberOfGuesses = 0; Table ta... |
### Question:
Row { public boolean matches(Guess guess) { return this.guess.nrOfPartialMatches(guess) == partial && this.guess.nrOfFullMatches(guess) == full; } Row(Guess guess, int full, int partial); protected Row(Row cloneFrom); void setFull(int full); void setPartial(int partial); boolean matches(Guess guess); int... |
### Question:
Game { public Row addNewGuess(Guess guess) { final int full = secret.nrOfFullMatches(guess); final int partial = secret.nrOfPartialMatches(guess); return addGuess(guess, full, partial); } Game(Table table, Guess secret); void setFinished(); Row addGuess(Guess guess, int full, int partial); Row addNewGuess... |
### Question:
ColorManager { public Color firstColor() { return first; } @Inject ColorManager(@Named("nrColors") int nrColors, ColorFactory factory); Color firstColor(); boolean thereIsNextColor(Color color); Color nextColor(Color color); int getNrColors(); }### Answer:
@Test public void thereIsAFirstColor() { ColorM... |
### Question:
ColorManager { public Color nextColor(Color color) { return successor.get(color); } @Inject ColorManager(@Named("nrColors") int nrColors, ColorFactory factory); Color firstColor(); boolean thereIsNextColor(Color color); Color nextColor(Color color); int getNrColors(); }### Answer:
@Test public void noCo... |
### Question:
UniqueGuesser extends Guesser { @Override protected Guess nextGuess() { Guess guess = super.nextGuess(); while (!guess.isUnique()) { guess = super.nextGuess(); } return guess; } UniqueGuesser(Table table); }### Answer:
@Test public void generateAllGuesses() { int numberOfGuesses = 0; Table table = new T... |
### Question:
Row { public boolean matches(Guess guess) { return this.guess.nrOfPartialMatches(guess) == partial && this.guess.nrOfFullMatches(guess) == full; } Row(Guess guess, int full, int partial); protected Row(Row cloneFrom); boolean matches(Guess guess); int nrOfColumns(); String toString(); static final Row no... |
### Question:
Game { public Row addNewGuess(Guess guess) { assertNotFinished(); final int full = secret.nrOfFullMatches(guess); final int partial = secret.nrOfPartialMatches(guess); final Row row = new Row(guess,full,partial); table.addRow(row); if (itWasAWinningGuess(full)) { finished = true; } return row; } Game(Tabl... |
### Question:
ColorManager { public Color firstColor() { return first; } ColorManager(int nrColors, ColorFactory factory); Color firstColor(); boolean thereIsNextColor(Color color); Color nextColor(Color color); int getNrColors(); }### Answer:
@Test public void thereIsAFirstColor() { ColorManager manager = new ColorMa... |
### Question:
ColorManager { public Color nextColor(Color color) { return successor.get(color); } ColorManager(int nrColors, ColorFactory factory); Color firstColor(); boolean thereIsNextColor(Color color); Color nextColor(Color color); int getNrColors(); }### Answer:
@Test public void noColorHasNoNextColor() { ColorM... |
### Question:
Partitioner { public int partition(SortableCollection<E> sortable, int start, int end, E pivot) { int small = start; int large = end; while (large > small) { while (comparator.compare(sortable.get(small), pivot) < 0 && small < large ) { small++; } while (comparator.compare(sortable.get(large), pivot) >= 0... |
### Question:
UniqueGuesser extends Guesser { @Override protected Color[] nextGuess() { Color[] guess = super.nextGuess(); while (isNotUnique(guess)) { guess = super.nextGuess(); } return guess; } UniqueGuesser(Table table); }### Answer:
@Test public void generateAllGuesses() { int numberOfGuesses = 0; ColorManager m... |
### Question:
Row { public void setMatch(int matchedPositions, int matchedColors) { if (matchedColors + matchedPositions > positions.length) { throw new IllegalArgumentException( "Number of matches can not be more that the position."); } this.matchedColors = matchedColors; this.matchedPositions = matchedPositions; } Ro... |
### Question:
Game { public void addNewGuess(Row row) { if (isFinished()) { throw new IllegalArgumentException("You can not guess on a finished game."); } final int positionMatch = secretRow.nrMatchingPositions(row.positions); final int colorMatch = secretRow.nrMatchingColors(row.positions); row.setMatch(positionMatch,... |
### Question:
ColorManager { public Color firstColor() { return first; } ColorManager(int nrColors); Color firstColor(); Color nextColor(Color color); }### Answer:
@Test public void thereIsAFirstColor() { ColorManager manager = new ColorManager(NR_COLORS); System.out.println(manager.firstColor()); Assert.assertNotNull... |
### Question:
ColorManager { public Color nextColor(Color color) { return successor.get(color); } ColorManager(int nrColors); Color firstColor(); Color nextColor(Color color); }### Answer:
@Test public void noColorHasNoNextColor() { ColorManager manager = new ColorManager(NR_COLORS); Assert.assertNull(manager.nextColo... |
### Question:
AwsS3Utils { static String checkBucketIsAccessible(AmazonS3 amazonS3, String bucketName) { HeadBucketRequest headBucketRequest = new HeadBucketRequest(bucketName); try { amazonS3.headBucket(headBucketRequest); } catch (AmazonServiceException e) { throw new AwsS3Exception("Bucket is not accessible", args -... |
### Question:
StoreManagerBuilderConfigurator { static String getProperty(Properties properties, String key) { String property = properties.getProperty(key); if (property != null) { StringBuffer result = new StringBuffer(); Matcher matcher = VARIABLE_REGEX_PATTERN.matcher(property); while (matcher.find()) { String name... |
### Question:
SnapshotPostProcessor { @VisibleForTesting static long updateVersionAndCheckConsistency(long localVersion, long newVersion, String errorMessage) { if (localVersion == -1) { return newVersion; } else { if (localVersion != newVersion) { throw new UnrecoverableStoreException(errorMessage, args -> args.add("l... |
### Question:
SnapshotPostProcessor { long getConsistentApplicationModelVersion() { long applicationModelVersion = 0; if (m_beforePostProcessingVersion > 0) { applicationModelVersion = m_beforePostProcessingVersion; } if (m_afterPostProcessingVersion > 0) { applicationModelVersion = m_afterPostProcessingVersion; } retu... |
### Question:
SnapshotPostProcessor { SerializableSnapshot apply(String storeName, SerializableSnapshot serializableSnapshot) { m_beforePostProcessingVersion = updateVersionAndCheckConsistency(m_beforePostProcessingVersion, serializableSnapshot.getApplicationModelVersion(), "Snapshot serializable application model vers... |
### Question:
OAuthAsyncCompletionHandler extends AsyncCompletionHandler<T> { @Override public T onCompleted(com.ning.http.client.Response ningResponse) { try { final Map<String, String> headersMap = new HashMap<>(); for (Map.Entry<String, List<String>> header : ningResponse.getHeaders().entrySet()) { final StringBuild... |
### Question:
HMACSha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); Preconditions.checkEmptyString(apiSecret, "Api secret cant be... |
### Question:
RSASha1SignatureService implements SignatureService { @Override public String getSignatureMethod() { return METHOD; } RSASha1SignatureService(PrivateKey privateKey); @Override String getSignature(String baseString, String apiSecret, String tokenSecret); @Override String getSignatureMethod(); }### Answer:... |
### Question:
RSASha1SignatureService implements SignatureService { @Override public String getSignature(String baseString, String apiSecret, String tokenSecret) { try { final Signature signature = Signature.getInstance(RSA_SHA1); signature.initSign(privateKey); signature.update(baseString.getBytes(UTF8)); return BASE_... |
### Question:
ParameterList { public String appendTo(String url) { Preconditions.checkNotNull(url, "Cannot append to null URL"); final String queryString = asFormUrlEncodedString(); if (queryString.equals(EMPTY_STRING)) { return url; } else { return url + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARA... |
### Question:
Token implements Serializable { public String getParameter(String parameter) { String value = null; for (String str : rawResponse.split("&")) { if (str.startsWith(parameter + '=')) { final String[] part = str.split("="); if (part.length > 1) { value = part[1].trim(); } break; } } return value; } protected... |
### Question:
MultipartUtils { public static void checkBoundarySyntax(String boundary) { if (boundary == null || !BOUNDARY_REGEXP.matcher(boundary).matches()) { throw new IllegalArgumentException("{'boundary'='" + boundary + "'} has invalid syntax. Should be '" + BOUNDARY_PATTERN + "'."); } } private MultipartUtils();... |
### Question:
Preconditions { public static void checkNotNull(Object object, String errorMsg) { check(object != null, errorMsg); } static void checkNotNull(Object object, String errorMsg); static void checkEmptyString(String string, String errorMsg); static boolean hasText(String str); }### Answer:
@Test(expected = I... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.