src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
AnnotationValues { public static byte getByte(AnnotationValue value) { return valueOfType(value, Byte.class); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(AnnotationValue value); st... | @Test public void getByte() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "byteValue"); assertThat(AnnotationValues.getByte(value)).isEqualTo((byte) 7); } |
AnnotationValues { public static ImmutableList<Byte> getBytes(AnnotationValue value) { return BYTES_VISITOR.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(AnnotationValu... | @Test public void getBytes() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "byteValues"); assertThat(AnnotationValues.getBytes(value)).containsExactly((byte) 8, (byte) 9).inOrder(); } |
AnnotationValues { public static short getShort(AnnotationValue value) { return valueOfType(value, Short.class); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(AnnotationValue value);... | @Test public void getShort() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "shortValue"); assertThat(AnnotationValues.getShort(value)).isEqualTo((short) 10); } |
AnnotationValues { public static ImmutableList<Short> getShorts(AnnotationValue value) { return SHORTS_VISITOR.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(AnnotationV... | @Test public void getShorts() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "shortValues"); assertThat(AnnotationValues.getShorts(value)).containsExactly((short) 11, (short) 12).inOrder(); } |
AnnotationValues { public static float getFloat(AnnotationValue value) { return valueOfType(value, Float.class); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(AnnotationValue value);... | @Test public void getFloat() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "floatValue"); assertThat(AnnotationValues.getFloat(value)).isEqualTo(13F); } |
AnnotationValues { public static ImmutableList<Float> getFloats(AnnotationValue value) { return FLOATS_VISITOR.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(AnnotationV... | @Test public void getFloats() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "floatValues"); assertThat(AnnotationValues.getFloats(value)).containsExactly(14F, 15F).inOrder(); } |
AnnotationValues { public static double getDouble(AnnotationValue value) { return valueOfType(value, Double.class); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(AnnotationValue valu... | @Test public void getDouble() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "doubleValue"); assertThat(AnnotationValues.getDouble(value)).isEqualTo(16D); } |
AnnotationValues { public static ImmutableList<Double> getDoubles(AnnotationValue value) { return DOUBLES_VISITOR.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(Annotati... | @Test public void getDoubles() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "doubleValues"); assertThat(AnnotationValues.getDoubles(value)).containsExactly(17D, 18D).inOrder(); } |
AnnotationValues { public static boolean getBoolean(AnnotationValue value) { return valueOfType(value, Boolean.class); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(AnnotationValue v... | @Test public void getBoolean() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "booleanValue"); assertThat(AnnotationValues.getBoolean(value)).isTrue(); } |
AnnotationValues { public static ImmutableList<Boolean> getBooleans(AnnotationValue value) { return BOOLEANS_VISITOR.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(Annot... | @Test public void getBooleans() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "booleanValues"); assertThat(AnnotationValues.getBooleans(value)).containsExactly(true, false).inOrder(); } |
AnnotationValues { public static char getChar(AnnotationValue value) { return valueOfType(value, Character.class); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(AnnotationValue value... | @Test public void getChar() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "charValue"); assertThat(AnnotationValues.getChar(value)).isEqualTo('a'); } |
AnnotationValues { public static ImmutableList<Character> getChars(AnnotationValue value) { return CHARS_VISITOR.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(Annotatio... | @Test public void getChars() { AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "charValues"); assertThat(AnnotationValues.getChars(value)).containsExactly('b', 'c').inOrder(); } |
SerializerFactoryImpl implements SerializerFactory { @Override public Serializer getSerializer(TypeMirror typeMirror) { for (SerializerExtension extension : extensions) { Optional<Serializer> serializer = extension.getSerializer(typeMirror, this, env); if (serializer.isPresent()) { return serializer.get(); } } return I... | @Test public void getSerializer_emptyFactories_identitySerializerReturned() throws Exception { SerializerFactoryImpl factory = new SerializerFactoryImpl(ImmutableList.of(), mockProcessingEnvironment); Serializer actualSerializer = factory.getSerializer(typeMirrorOf(String.class)); assertThat(actualSerializer.getClass()... |
ImmutableMapSerializerExtension implements SerializerExtension { @Override public Optional<Serializer> getSerializer( TypeMirror typeMirror, SerializerFactory factory, ProcessingEnvironment processingEnv) { if (!isImmutableMap(typeMirror)) { return Optional.empty(); } TypeMirror keyType = getKeyType(typeMirror); TypeMi... | @Test public void getSerializer_nonImmutableMap_emptyReturned() { TypeMirror typeMirror = typeMirrorOf(String.class); Optional<Serializer> actualSerializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment); assertThat(actualSerializer).isEmpty(); }
@Test public void getSerializer_i... |
ImmutableListSerializerExtension implements SerializerExtension { @Override public Optional<Serializer> getSerializer( TypeMirror typeMirror, SerializerFactory factory, ProcessingEnvironment processingEnv) { if (!isImmutableList(typeMirror)) { return Optional.empty(); } TypeMirror containedType = getContainedType(typeM... | @Test public void getSerializer_nonImmutableList_emptyReturned() { TypeMirror typeMirror = typeMirrorOf(String.class); Optional<Serializer> actualSerializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment); assertThat(actualSerializer).isEmpty(); }
@Test public void getSerializer_... |
IdentitySerializerFactory { public static Serializer getSerializer(TypeMirror typeMirror) { return new IdentitySerializer(typeMirror); } private IdentitySerializerFactory(); static Serializer getSerializer(TypeMirror typeMirror); } | @Test public void proxyFieldType_isUnchanged() throws Exception { TypeMirror typeMirror = typeMirrorOf(String.class); TypeMirror actualTypeMirror = IdentitySerializerFactory.getSerializer(typeMirror).proxyFieldType(); assertThat(actualTypeMirror).isSameInstanceAs(typeMirror); }
@Test public void toProxy_isUnchanged() t... |
Reformatter { static String fixup(String s) { StringBuilder out = new StringBuilder(); JavaScanner scanner = new JavaScanner(s); s = scanner.string(); int len = s.length(); for (int start = 0, previous = 0, braces = 0, parens = 0, end = 0; start < len; previous = start, start = end) { end = scanner.tokenEnd(start); swi... | @Test public void testSimple() { String input = "\n" + "package com.latin.declension; \n" + "\n" + "\n" + "public class Idem { \n" + " \n" + " Eadem idem ; \n" + "\n" + " Eundem eandem ( Idem eiusdem ) {\n" + "\n" + " eiusdem ( eiusdem ) ; \n" + "\n" + " eidem_eidem_eidem( ) ;\n" + "\n" + " }\n" + "\n" + "\n" + " Eodem... |
SimpleServiceLoader { public static <T> ImmutableList<T> load(Class<? extends T> service, ClassLoader loader) { String resourceName = "META-INF/services/" + service.getName(); List<URL> resourceUrls; try { resourceUrls = Collections.list(loader.getResources(resourceName)); } catch (IOException e) { throw new ServiceCon... | @Test public void loadOnce() throws Exception { ClassLoader loader = loaderForJarWithEntries( CharSequence.class.getName(), String.class.getName(), StringBuilder.class.getName()); ImmutableList<CharSequence> providers = SimpleServiceLoader.load(CharSequence.class, loader); assertThat(providers).contains(""); List<Class... |
TemplateVars { String toText() { Map<String, Object> vars = toVars(); return parsedTemplate().evaluate(vars); } TemplateVars(); } | @Test public void testHappy() { HappyVars happy = new HappyVars(); happy.integer = 23; happy.string = "wibble"; happy.list = ImmutableList.of(5, 17, 23); assertThat(HappyVars.IGNORED_STATIC_FINAL).isEqualTo("hatstand"); String expectedText = "integer=23 string=wibble list=[5, 17, 23]"; String actualText = happy.toText(... |
JavaScanner { int tokenEnd(int start) { if (start >= s.length()) { return s.length(); } switch (s.charAt(start)) { case ' ': case '\n': return spaceEnd(start); case '/': if (s.charAt(start + 1) == '*') { return blockCommentEnd(start); } else if (s.charAt(start + 1) == '/') { return lineCommentEnd(start); } else { retur... | @Test public void testScanner() { String input = Joiner.on("").join(TOKENS); ImmutableList.Builder<String> tokensBuilder = ImmutableList.builder(); JavaScanner tokenizer = new JavaScanner(input); int end; for (int i = 0; i < input.length(); i = end) { end = tokenizer.tokenEnd(i); tokensBuilder.add(input.substring(i, en... |
TypeVariables { static ImmutableMap<ExecutableElement, TypeMirror> rewriteReturnTypes( Elements elementUtils, Types typeUtils, Collection<ExecutableElement> methods, TypeElement sourceType, TypeElement targetType) { List<? extends TypeParameterElement> sourceTypeParameters = sourceType.getTypeParameters(); List<? exten... | @Test public void noTypeParameters() { TypeElement source1 = elementUtils.getTypeElement(Source1.class.getCanonicalName()); TypeElement target1 = elementUtils.getTypeElement(Target1.class.getCanonicalName()); List<ExecutableElement> sourceMethods = ElementFilter.methodsIn(source1.getEnclosedElements()); Map<ExecutableE... |
TypeVariables { static boolean canAssignStaticMethodResult( ExecutableElement method, TypeMirror actualParameterType, TypeMirror targetType, Types typeUtils) { if (!targetType.getKind().equals(TypeKind.DECLARED) || !method.getModifiers().contains(Modifier.STATIC) || method.getParameters().size() != 1) { return false; }... | @Test public void canAssignStaticMethodResult() { TypeElement immutableMap = elementUtils.getTypeElement(ImmutableMap.class.getCanonicalName()); TypeElement string = elementUtils.getTypeElement(String.class.getCanonicalName()); TypeElement integer = elementUtils.getTypeElement(Integer.class.getCanonicalName()); TypeEle... |
PropertyNames { static String decapitalizeLikeJavaBeans(String propertyName) { if (propertyName != null && propertyName.length() >= 2 && Character.isUpperCase(propertyName.charAt(0)) && Character.isUpperCase(propertyName.charAt(1))) { return propertyName; } return decapitalizeNormally(propertyName); } } | @Test public void decapitalizeLikeJavaBeans() { NORMAL_CASES .forEach( (input, output) -> { expect.that(PropertyNames.decapitalizeLikeJavaBeans(input)).isEqualTo(output); }); expect.that(PropertyNames.decapitalizeLikeJavaBeans(null)).isNull(); expect.that(PropertyNames.decapitalizeLikeJavaBeans("HTMLPage")).isEqualTo("... |
PropertyNames { static String decapitalizeNormally(String propertyName) { if (Strings.isNullOrEmpty(propertyName)) { return propertyName; } return Character.toLowerCase(propertyName.charAt(0)) + propertyName.substring(1); } } | @Test public void decapitalizeNormally() { NORMAL_CASES .forEach( (input, output) -> { expect.that(PropertyNames.decapitalizeNormally(input)).isEqualTo(output); }); expect.that(PropertyNames.decapitalizeNormally(null)).isNull(); expect.that(PropertyNames.decapitalizeNormally("HTMLPage")).isEqualTo("hTMLPage"); expect.t... |
TypeSimplifier { static String packageNameOf(TypeElement type) { return MoreElements.getPackage(type).getQualifiedName().toString(); } TypeSimplifier(
Elements elementUtils,
Types typeUtils,
String packageName,
Set<TypeMirror> types,
TypeMirror base); } | @Test public void testPackageNameOfString() { assertThat(TypeSimplifier.packageNameOf(typeElementOf(java.lang.String.class))) .isEqualTo("java.lang"); }
@Test public void testPackageNameOfMapEntry() { assertThat(TypeSimplifier.packageNameOf(typeElementOf(java.util.Map.Entry.class))) .isEqualTo("java.util"); } |
TypeSimplifier { static boolean isCastingUnchecked(TypeMirror type) { return CASTING_UNCHECKED_VISITOR.visit(type, null); } TypeSimplifier(
Elements elementUtils,
Types typeUtils,
String packageName,
Set<TypeMirror> types,
TypeMirror base); } | @Test public void testIsCastingUnchecked() { TypeElement erasureClass = typeElementOf(Erasure.class); List<VariableElement> fields = ElementFilter.fieldsIn(erasureClass.getEnclosedElements()); assertThat(fields).isNotEmpty(); for (VariableElement field : fields) { String fieldName = field.getSimpleName().toString(); bo... |
SimpleValueType { public static SimpleValueType create( @Nullable String string, int integer, Map<String, Long> map) { return new AutoValue_SimpleValueType(string, integer, map); } @Nullable abstract String string(); abstract int integer(); abstract Map<String, Long> map(); static SimpleValueType create(
@Nullab... | @Test public void testNestedValueType() { ImmutableMap<Integer, String> numberNames = ImmutableMap.of(1, "un", 2, "deux"); NestedValueType.Nested nested = NestedValueType.Nested.create(numberNames); assertEquals(numberNames, nested.numberNames()); } |
PackagelessValueType { public static PackagelessValueType create( @Nullable String string, int integer, Map<String, Long> map) { return new AutoValue_PackagelessValueType(string, integer, map); } @Nullable abstract String string(); abstract int integer(); abstract Map<String, Long> map(); static PackagelessValueType c... | @Test public void testNestedValueType() { ImmutableMap<Integer, String> numberNames = ImmutableMap.of(1, "un", 2, "deux"); PackagelessNestedValueType.Nested nested = PackagelessNestedValueType.Nested.create(numberNames); assertEquals(numberNames, nested.numberNames()); } |
SuperficialValidation { public static boolean validateElement(Element element) { return element.accept(ELEMENT_VALIDATING_VISITOR, null); } private SuperficialValidation(); static boolean validateElements(Iterable<? extends Element> elements); static boolean validateElement(Element element); static boolean validateTyp... | @Test public void missingReturnType() { JavaFileObject javaFileObject = JavaFileObjects.forSourceLines( "test.TestClass", "package test;", "", "abstract class TestClass {", " abstract MissingType blah();", "}"); assertAbout(javaSource()) .that(javaFileObject) .processedWith(new AssertingProcessor() { @Override void run... |
BasicAnnotationProcessor extends AbstractProcessor { protected static Step asStep(ProcessingStep processingStep) { return new ProcessingStepAsStep(processingStep); } @Override final synchronized void init(ProcessingEnvironment processingEnv); @Override final ImmutableSet<String> getSupportedAnnotationTypes(); @Overrid... | @Test public void processingStepAsStepAnnotationsNamesMatchClasses() { Step step = BasicAnnotationProcessor.asStep(new MultiAnnotationProcessingStep()); assertThat(step.annotations()) .containsExactly( AnAnnotation.class.getCanonicalName(), ReferencesAClass.class.getCanonicalName()); } |
MoreElements { public static PackageElement getPackage(Element element) { while (element.getKind() != PACKAGE) { element = element.getEnclosingElement(); } return (PackageElement) element; } private MoreElements(); static PackageElement getPackage(Element element); static PackageElement asPackage(Element element); sta... | @Test public void getPackage() { assertThat(MoreElements.getPackage(stringElement)).isEqualTo(javaLangPackageElement); for (Element childElement : stringElement.getEnclosedElements()) { assertThat(MoreElements.getPackage(childElement)).isEqualTo(javaLangPackageElement); } } |
MoreElements { public static PackageElement asPackage(Element element) { return element.accept(PackageElementVisitor.INSTANCE, null); } private MoreElements(); static PackageElement getPackage(Element element); static PackageElement asPackage(Element element); static boolean isType(Element element); static TypeElement... | @Test public void asPackage() { assertThat(MoreElements.asPackage(javaLangPackageElement)) .isEqualTo(javaLangPackageElement); }
@Test public void asPackage_illegalArgument() { try { MoreElements.asPackage(stringElement); fail(); } catch (IllegalArgumentException expected) {} } |
MoreElements { public static TypeParameterElement asTypeParameter(Element element) { return element.accept(TypeParameterElementVisitor.INSTANCE, null); } private MoreElements(); static PackageElement getPackage(Element element); static PackageElement asPackage(Element element); static boolean isType(Element element); ... | @Test public void asTypeParameterElement() { Element typeParameterElement = getOnlyElement( compilation .getElements() .getTypeElement(List.class.getCanonicalName()) .getTypeParameters()); assertThat(MoreElements.asTypeParameter(typeParameterElement)).isEqualTo(typeParameterElement); }
@Test public void asTypeParameter... |
MoreElements { public static TypeElement asType(Element element) { return element.accept(TypeElementVisitor.INSTANCE, null); } private MoreElements(); static PackageElement getPackage(Element element); static PackageElement asPackage(Element element); static boolean isType(Element element); static TypeElement asType(E... | @Test public void asType() { assertThat(MoreElements.asType(stringElement)).isEqualTo(stringElement); } |
MoreElements { public static VariableElement asVariable(Element element) { return element.accept(VariableElementVisitor.INSTANCE, null); } private MoreElements(); static PackageElement getPackage(Element element); static PackageElement asPackage(Element element); static boolean isType(Element element); static TypeElem... | @Test public void asVariable() { for (Element variableElement : ElementFilter.fieldsIn(stringElement.getEnclosedElements())) { assertThat(MoreElements.asVariable(variableElement)).isEqualTo(variableElement); } }
@Test public void asVariable_illegalArgument() { try { MoreElements.asVariable(javaLangPackageElement); fail... |
MoreElements { public static ExecutableElement asExecutable(Element element) { return element.accept(ExecutableElementVisitor.INSTANCE, null); } private MoreElements(); static PackageElement getPackage(Element element); static PackageElement asPackage(Element element); static boolean isType(Element element); static Ty... | @Test public void asExecutable() { for (Element methodElement : ElementFilter.methodsIn(stringElement.getEnclosedElements())) { assertThat(MoreElements.asExecutable(methodElement)).isEqualTo(methodElement); } for (Element methodElement : ElementFilter.constructorsIn(stringElement.getEnclosedElements())) { assertThat(Mo... |
MoreElements { public static boolean isAnnotationPresent(Element element, Class<? extends Annotation> annotationClass) { return getAnnotationMirror(element, annotationClass).isPresent(); } private MoreElements(); static PackageElement getPackage(Element element); static PackageElement asPackage(Element element); stati... | @Test public void isAnnotationPresent() { TypeElement annotatedAnnotationElement = compilation.getElements().getTypeElement(AnnotatedAnnotation.class.getCanonicalName()); assertThat(MoreElements.isAnnotationPresent(annotatedAnnotationElement, Documented.class)) .isTrue(); assertThat(MoreElements.isAnnotationPresent(ann... |
MoreElements { public static Optional<AnnotationMirror> getAnnotationMirror(Element element, Class<? extends Annotation> annotationClass) { String annotationClassName = annotationClass.getCanonicalName(); for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) { TypeElement annotationTypeElement = asTy... | @Test public void getAnnotationMirror() { TypeElement element = compilation.getElements().getTypeElement(AnnotatedAnnotation.class.getCanonicalName()); Optional<AnnotationMirror> documented = MoreElements.getAnnotationMirror(element, Documented.class); Optional<AnnotationMirror> innerAnnotation = MoreElements.getAnnota... |
MoreElements { @Deprecated public static ImmutableSet<ExecutableElement> getLocalAndInheritedMethods( TypeElement type, Elements elementUtils) { Overrides overrides = new Overrides.NativeOverrides(elementUtils); return getLocalAndInheritedMethods(type, overrides); } private MoreElements(); static PackageElement getPac... | @Test public void getLocalAndInheritedMethods_Old() { Elements elements = compilation.getElements(); Types types = compilation.getTypes(); TypeMirror intMirror = types.getPrimitiveType(TypeKind.INT); TypeMirror longMirror = types.getPrimitiveType(TypeKind.LONG); TypeElement childType = elements.getTypeElement(Child.cla... |
MoreElements { public static ImmutableSet<ExecutableElement> getAllMethods( TypeElement type, Types typeUtils, Elements elementUtils) { return getAllMethods(type, new ExplicitOverrides(typeUtils)); } private MoreElements(); static PackageElement getPackage(Element element); static PackageElement asPackage(Element elem... | @Test public void getAllMethods() { Elements elements = compilation.getElements(); Types types = compilation.getTypes(); TypeMirror intMirror = types.getPrimitiveType(TypeKind.INT); TypeMirror longMirror = types.getPrimitiveType(TypeKind.LONG); TypeElement childType = elements.getTypeElement(Child.class.getCanonicalNam... |
MoreTypes { public static Equivalence<TypeMirror> equivalence() { return TypeEquivalence.INSTANCE; } private MoreTypes(); static Equivalence<TypeMirror> equivalence(); static ImmutableSet<TypeElement> referencedTypes(TypeMirror type); static Element asElement(TypeMirror typeMirror); static TypeElement asTypeElement(Ty... | @Test public void equivalence() { Types types = compilationRule.getTypes(); Elements elements = compilationRule.getElements(); TypeMirror objectType = elements.getTypeElement(Object.class.getCanonicalName()).asType(); TypeMirror stringType = elements.getTypeElement(String.class.getCanonicalName()).asType(); TypeElement... |
MoreTypes { public static ImmutableSet<TypeElement> referencedTypes(TypeMirror type) { checkNotNull(type); ImmutableSet.Builder<TypeElement> elements = ImmutableSet.builder(); type.accept(ReferencedTypes.INSTANCE, elements); return elements.build(); } private MoreTypes(); static Equivalence<TypeMirror> equivalence(); ... | @Test public void testReferencedTypes() { Elements elements = compilationRule.getElements(); TypeElement testDataElement = elements .getTypeElement(ReferencedTypesTestData.class.getCanonicalName()); ImmutableMap<String, VariableElement> fieldIndex = FluentIterable.from(ElementFilter.fieldsIn(testDataElement.getEnclosed... |
MoreTypes { public static Element asElement(TypeMirror typeMirror) { return typeMirror.accept(AsElementVisitor.INSTANCE, null); } private MoreTypes(); static Equivalence<TypeMirror> equivalence(); static ImmutableSet<TypeElement> referencedTypes(TypeMirror type); static Element asElement(TypeMirror typeMirror); static... | @Test public void asElement_throws() { TypeMirror javaDotLang = compilationRule.getElements().getPackageElement("java.lang").asType(); try { MoreTypes.asElement(javaDotLang); fail(); } catch (IllegalArgumentException expected) {} }
@Test public void asElement() { Elements elements = compilationRule.getElements(); TypeE... |
MoreTypes { public static Optional<DeclaredType> nonObjectSuperclass(Types types, Elements elements, DeclaredType type) { checkNotNull(types); checkNotNull(elements); checkNotNull(type); TypeMirror superclassType = asTypeElement(type).getSuperclass(); if (!isType(superclassType)) { return Optional.absent(); } DeclaredT... | @Test public void testNonObjectSuperclass() { Types types = compilationRule.getTypes(); Elements elements = compilationRule.getElements(); TypeMirror numberType = elements.getTypeElement(Number.class.getCanonicalName()).asType(); TypeMirror stringType = elements.getTypeElement(String.class.getCanonicalName()).asType();... |
MoreTypes { public static boolean isConversionFromObjectUnchecked(TypeMirror type) { return new CastingUncheckedVisitor().visit(type, null); } private MoreTypes(); static Equivalence<TypeMirror> equivalence(); static ImmutableSet<TypeElement> referencedTypes(TypeMirror type); static Element asElement(TypeMirror typeMi... | @Test public void testIsConversionFromObjectUnchecked_yes() { Elements elements = compilationRule.getElements(); TypeElement unchecked = elements.getTypeElement(Unchecked.class.getCanonicalName()); for (VariableElement field : ElementFilter.fieldsIn(unchecked.getEnclosedElements())) { TypeMirror type = field.asType(); ... |
SimpleTypeAnnotationValue implements AnnotationValue { public static AnnotationValue of(TypeMirror value) { return new SimpleTypeAnnotationValue(value); } private SimpleTypeAnnotationValue(TypeMirror value); static AnnotationValue of(TypeMirror value); @Override TypeMirror getValue(); @Override String toString(); @Ove... | @Test public void arrays() { SimpleTypeAnnotationValue.of(types.getArrayType(objectType)); SimpleTypeAnnotationValue.of(types.getArrayType(primitiveType)); }
@Test public void declaredType() { SimpleTypeAnnotationValue.of(objectType); }
@Test public void parameterizedType() { try { SimpleTypeAnnotationValue.of( types.g... |
SimpleAnnotationMirror implements AnnotationMirror { public static AnnotationMirror of(TypeElement annotationType) { return of(annotationType, ImmutableMap.of()); } private SimpleAnnotationMirror(
TypeElement annotationType, Map<String, ? extends AnnotationValue> namedValues); static AnnotationMirror of(TypeElem... | @Test public void extraValues() { TypeElement multipleValues = getTypeElement(MultipleValues.class); Map<String, AnnotationValue> values = new HashMap<>(); values.put("value1", intValue(1)); values.put("value2", intValue(2)); values.put("value3", intValue(3)); expectThrows(() -> SimpleAnnotationMirror.of(multipleValues... |
AnnotationMirrors { public static Equivalence<AnnotationMirror> equivalence() { return ANNOTATION_MIRROR_EQUIVALENCE; } private AnnotationMirrors(); static Equivalence<AnnotationMirror> equivalence(); static ImmutableMap<ExecutableElement, AnnotationValue> getAnnotationValuesWithDefaults(
AnnotationMirror annota... | @Test public void testEquivalences() { EquivalenceTester<AnnotationMirror> tester = EquivalenceTester.of(AnnotationMirrors.equivalence()); tester.addEquivalenceGroup( annotationOn(SimplyAnnotated.class), annotationOn(AlsoSimplyAnnotated.class)); tester.addEquivalenceGroup( annotationOn(TestClassBlah.class), annotationO... |
AnnotationMirrors { public static ImmutableMap<ExecutableElement, AnnotationValue> getAnnotationValuesWithDefaults( AnnotationMirror annotation) { ImmutableMap.Builder<ExecutableElement, AnnotationValue> values = ImmutableMap.builder(); Map<? extends ExecutableElement, ? extends AnnotationValue> declaredValues = annota... | @Test public void testGetDefaultValuesUnset() { assertThat(annotationOn(StringyUnset.class).getElementValues()).isEmpty(); Iterable<AnnotationValue> values = AnnotationMirrors.getAnnotationValuesWithDefaults( annotationOn(StringyUnset.class)).values(); String value = getOnlyElement(values).accept(new SimpleAnnotationVa... |
AnnotationMirrors { public static AnnotationValue getAnnotationValue( AnnotationMirror annotationMirror, String elementName) { return getAnnotationElementAndValue(annotationMirror, elementName).getValue(); } private AnnotationMirrors(); static Equivalence<AnnotationMirror> equivalence(); static ImmutableMap<Executable... | @Test public void testGetValueEntryFailure() { try { AnnotationMirrors.getAnnotationValue(annotationOn(TestClassBlah.class), "a"); } catch (IllegalArgumentException e) { assertThat(e) .hasMessageThat() .isEqualTo( "@com.google.auto.common.AnnotationMirrorsTest.Outer does not define an element a()"); return; } fail("Sho... |
AnnotationValues { public static DeclaredType getTypeMirror(AnnotationValue value) { return TypeMirrorVisitor.INSTANCE.visit(value); } private AnnotationValues(); static Equivalence<AnnotationValue> equivalence(); static DeclaredType getTypeMirror(AnnotationValue value); static AnnotationMirror getAnnotationMirror(Ann... | @Test public void getTypeMirror() { TypeElement insideClassA = getTypeElement(InsideClassA.class); AnnotationValue value = AnnotationMirrors.getAnnotationValue(annotationMirror, "classValue"); assertThat(AnnotationValues.getTypeMirror(value).asElement()).isEqualTo(insideClassA); }
@Test public void getTypeMirrorGeneric... |
BaseActionImpl { public BaseActionImpl() { } BaseActionImpl(); BaseActionImpl(InferenceConfigDefinition kpiDefinition); } | @Test public void testBaseActionImpl() { assertEquals("AVERAGE",ExecutionActions.AVERAGE.toString()); } |
OfflineDataProcessingExecutor extends TimerTask { public Boolean executeCypherQuery(String cypherQuery, DataEnrichmentModel dataEnrichmentModel) { GraphDBHandler dbHandler = new GraphDBHandler(); int processedRecords = 1; int recordCount = 0; long queryExecutionStartTime = System.currentTimeMillis(); try { while (proce... | @Test public void testExecuteCypherQuery() { String cypherQuery = "MATCH (n:ALM) where not exists (n.processed) with n limit 100 set n.processed=true return count(n)"; DataEnrichmentModel model = new DataEnrichmentModel(); Boolean resultFlag = executor.executeCypherQuery(cypherQuery, model); assertTrue(resultFlag); }
@... |
OfflineDataProcessingExecutor extends TimerTask { public Boolean isQueryScheduledToRun(Long runSchedule, String lastRunTime, String cronSchedule) { if (lastRunTime == null && (cronSchedule == null || cronSchedule.trim().length() == 0)) { return Boolean.TRUE; } ZonedDateTime dateTime = null; ZonedDateTime now = ZonedDat... | @Test public void testIsQueryScheduledToRun() { Long runSchedule = 720L; String lastRunTime = "2018/07/16 05:50 PM"; assertTrue(executor.isQueryScheduledToRun(runSchedule, lastRunTime, null)); } |
BaseActionImpl { protected String getEsQueryWithDates(JobSchedule schedule, String esQuery) { Long fromDate = InsightsUtils.getDataFromTime(schedule.name()); esQuery = esQuery.replace("__dataFromTime__", fromDate.toString()); Long toDate = InsightsUtils.getDataToTime(schedule.name()); esQuery = esQuery.replace("__dataT... | @Test public void testGetEsQueryWithDates() { String esQuery = "query"; JobSchedule schedule = null; } |
CountActionImpl extends BaseActionImpl { @Override protected void execute() throws InsightsJobFailedException { executeNeo4jGraphQuery(); } CountActionImpl(InferenceConfigDefinition kpiDefinition); } | @Test public void testExecute() { load(); Map<String, Object> resultMap = new HashMap<String, Object>(); resultMap.put("Jobs", "Success"); } |
MinMaxActionImpl extends BaseActionImpl { @Override protected void execute() throws InsightsJobFailedException { executeNeo4jGraphQuery(); } MinMaxActionImpl(InferenceConfigDefinition kpiDefinition); } | @Test public void testExecute() throws InsightsJobFailedException { load(); Map<String, Object> resultMap = new HashMap<String, Object>(); resultMap.put("Jobs", "Success"); } |
OfflineDataProcessingExecutor extends TimerTask { public int executeOfflineProcessing() { File queryFolderPath = new File(ConfigOptions.OFFLINE_DATA_PROCESSING_RESOLVED_PATH); File[] files = queryFolderPath.listFiles(); int jsonFileCount = 0; if (files == null) { return jsonFileCount; } for (File eachFile : files) { if... | @Test public void testExecuteOfflineProcessingNegative() { AssertJUnit.assertNotSame(6, executor.executeOfflineProcessing()); } |
OfflineDataProcessingExecutor extends TimerTask { public Boolean hasJsonFileExtension(String fileName) { if (fileName != null && !fileName.isEmpty()) { String extension = FilenameUtils.getExtension(fileName); if (JSON_FILE_EXTENSION.equalsIgnoreCase(extension)) { return Boolean.TRUE; } } return Boolean.FALSE; } @Overr... | @Test public void testHasJsonFileExtension() { String fileName = "data-enrichment.JSON"; Boolean hasJsonFileExtension = executor.hasJsonFileExtension(fileName); assertTrue(hasJsonFileExtension); }
@Test public void testHasJsonFileExtensionNegative() { String fileName = "neo4j_import_json.py"; Boolean hasJsonFileExtensi... |
OfflineDataProcessingExecutor extends TimerTask { public Boolean processOfflineConfiguration(File jsonFile) { try { try (BufferedReader reader = new BufferedReader(new FileReader(jsonFile))) { DataEnrichmentModel[] dataEnrichmentModelArray = new Gson().fromJson(reader, DataEnrichmentModel[].class); List<DataEnrichmentM... | @Test public void testProcessOfflineConfiguration() { File configFile = new File(ConfigOptions.OFFLINE_DATA_PROCESSING_RESOLVED_PATH + ConfigOptions.FILE_SEPERATOR + ConfigOptions.DATA_ENRICHMENT_TEMPLATE); Boolean resultFlag = executor.processOfflineConfiguration(configFile); assertTrue(resultFlag); } |
OfflineDataProcessingExecutor extends TimerTask { public DataEnrichmentModel updateLastExecutionTime(DataEnrichmentModel dataEnrichmentModel) { String lastRunTime = InsightsUtils.getLocalDateTime(DATE_TIME_FORMAT); if (dataEnrichmentModel != null) { dataEnrichmentModel.setLastExecutionTime(lastRunTime); } return dataEn... | @Test public void testUpdateLastExecutionTime() { DataEnrichmentModel dataEnrichmentModel = new DataEnrichmentModel(); dataEnrichmentModel.setLastExecutionTime("2018/07/16 12:53 PM"); DataEnrichmentModel resultModel = executor.updateLastExecutionTime(dataEnrichmentModel); String currentTime = InsightsUtils.getLocalDate... |
HttpMatch { public Method[] findInterfaceMethods(String methodName) { Method[] methods = interfaceClass.getMethods(); List<Method> ret = new ArrayList<Method>(); for (Method method : methods) { if (method.getName().equals(methodName)) ret.add(method); } return ret.toArray(new Method[] {}); } HttpMatch(Class<?> interfac... | @Test public void testFindInterfaceMethods(){ Method[] findInterfaceMethods = httpMatch.findInterfaceMethods("login"); Assert.assertEquals(findInterfaceMethods.length, 2); findInterfaceMethods = httpMatch.findInterfaceMethods("get"); Assert.assertEquals(findInterfaceMethods.length, 2); findInterfaceMethods = httpMatch.... |
HttpMatch { public Method[] findRefMethods(Method[] interfaceMethods, String operationId, String requestMethod) { List<Method> ret = new ArrayList<Method>(); for (Method method : interfaceMethods) { Method m; try { m = refClass.getMethod(method.getName(), method.getParameterTypes()); final ApiOperation apiOperation = R... | @Test public void testFindRefMethods() throws NoSuchMethodException, SecurityException{ Method[] findInterfaceMethods = httpMatch.findInterfaceMethods("login"); Assert.assertEquals(findInterfaceMethods.length, 2); Method[] findRefMethods = httpMatch.findRefMethods(findInterfaceMethods, null, "POST"); Assert.assertEqual... |
Reader { public static void read(Swagger swagger, Set<Class<?>> classes) { final Reader reader = new Reader(swagger); for (Class<?> cls : classes) { final ReaderContext context = new ReaderContext(swagger, cls, cls, "", null, false, new ArrayList<String>(), new ArrayList<String>(), new ArrayList<String>(), new ArrayLis... | @SuppressWarnings({ "serial" }) @Test public void testApplyParameters(){ Swagger swagger = new Swagger(); Reader.read(swagger, new HashMap<Class<?>, Object>(){{ put(InterfaceServiceTest.class, new InterfaceServiceImplTest()); }}, "/h"); Map<String, Path> paths = swagger.getPaths(); Assert.assertEquals(paths.size(), 4);... |
HomePresenter extends BasePresenter<HomeContract.View> implements HomeContract.Presenter { @Override public void fetchUsers() { if (this.getView() != null) { this.getView().onLoading(true); this.addDisposable(mRepository.fetchUsers(this.getView().getPage()). subscribeOn(this.getScheduler().io()) .observeOn(this.getSche... | @Test public void fetchUsers_sucess(){ mPresenter.fetchUsers(); verify(mRepository, times(1)).fetchUsers(2); }
@Test public void fetchUsers_returning_loadingSuccess_forView() { mPresenter.fetchUsers(); verify(mView, times(1)).getPage(); verify(mView, times(1)).onLoading(true); mTestScheduler.triggerActions(); verify(mV... |
HomePresenter extends BasePresenter<HomeContract.View> implements HomeContract.Presenter { @Override public HomeContract.View getView() { return super.getView(); } @Inject HomePresenter(@NonNull HomeContract.Repository repository,
@NonNull BaseScheduler scheduler); @Override void fetchUsers();... | @Test public void attach_isNotNull_sucess(){ assertNotNull(mPresenter.getView()); }
@Test public void detachView_isNull_sucess(){ assertNotNull(mPresenter.getView()); mPresenter.detachView(); assertNull(mPresenter.getView()); } |
HomeRepository implements HomeContract.Repository { @Override public Single<UserResponse> fetchUsers(int page) { return this.endPointHelper.fetchUsers(page); } @Inject HomeRepository(EndPointHelper endPointHelper); @Override Single<UserResponse> fetchUsers(int page); } | @Test public void fetchUsers_sucess() { mRepository.fetchUsers(2); verify(mApiEndPointHelper).fetchUsers(2); }
@Test public void fetchUsers_noErros_sucess() { TestObserver<UserResponse> subscriber = TestObserver.create(); mApiEndPointHelper.fetchUsers(2).subscribe(subscriber); subscriber.onNext(new UserResponse()); sub... |
WsProducer extends DefaultProducer { public static void sendMessage(WebSocket webSocket, String msg, boolean streaming) { if (streaming && msg.length() > STREAM_BUFFER_SIZE) { int p = 0; while (p < msg.length()) { if (msg.length() - p < STREAM_BUFFER_SIZE) { webSocket.sendContinuationFrame(msg.substring(p), true, 0); p... | @Test public void testSendMessage() { var wsMockHelper = new WebSocketMockHelper(); getTestByteArrayStream().forEach(bytes -> { try { WsProducer.sendMessage(wsMockHelper.getMock(), bytes, false); assertArrayEquals("sendMessage() (bytes, non-streaming) seems flawed", bytes, wsMockHelper.getResultBytes()); wsMockHelper.r... |
DefProConfigurationLoader implements ConfigurationLoader { @Override @SuppressWarnings("IllegalCatch") public Configuration load(File file) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The given file does not exist"); } try { return new DefProConfiguration(APIProvider.getAPI(fil... | @Test public void nonExistentFile() throws Exception { File file = mock(File.class); when(file.exists()).thenReturn(false); assertThatThrownBy(() -> loader.load(file)).isInstanceOf(FileNotFoundException.class); }
@Test public void invalidFile() throws Exception { File file = mock(File.class); when(file.exists()).thenRe... |
Teleporter extends Tileable implements TileableListener { public void setDestination(Teleporter destination) { if (!track.getClass().equals(destination.getTrack().getClass())) { throw new IllegalStateException("Both connected teleporters must be either" + " horizontal or vertical"); } this.destination = destination; } ... | @Test public void setDestinationFail() { Teleporter vertTeleporter = new Teleporter(new VerticalTrack()); assertThatThrownBy(() -> vertTeleporter.setDestination(teleporter1)) .isInstanceOf(IllegalStateException.class); assertThatThrownBy(() -> teleporter1.setDestination(vertTeleporter)) .isInstanceOf(IllegalStateExcept... |
Teleporter extends Tileable implements TileableListener { @Override public void ballDisposed(Tileable tileable, Direction direction, Marble marble) { informDispose(direction, marble); } Teleporter(Track track); void setDestination(Teleporter destination); Track getTrack(); Teleporter getDestination(); @Override boolean... | @Test public void informDispose() { Direction direction = Direction.RIGHT; Marble marble = new Marble(MarbleType.BLUE); TileableListener listener = mock(TileableListener.class); teleporter1.addListener(listener); teleporter1.ballDisposed(teleporter1, direction, marble); verify(listener, times(1)).ballDisposed( teleport... |
HorizontalTrack extends Track { public boolean isConnected() { Tile tile = getTile(); if (tile == null) { throw new IllegalStateException("The track is not placed on a grid"); } Tile left = tile.get(Direction.LEFT); Tile right = tile.get(Direction.RIGHT); return left != null && right != null; } boolean isConnected(); ... | @Test public void isNotConnected() { Grid grid = new Grid(null, 1, 1); grid.place(0, 0, track); assertThat(track.isConnected()).isFalse(); }
@Test public void isNotConnectedLeft() { Grid grid = new Grid(null, 2, 1); grid.place(0, 0, new HorizontalTrack()); grid.place(1, 0, track); assertThat(track.isConnected()).isFals... |
HorizontalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case LEFT: case RIGHT: return true; default: return false; } } boolean isConnected(); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override boolean allowsConnection(Direction ... | @Test public void allowsLeft() { assertThat(track.allowsConnection(Direction.LEFT)).isTrue(); }
@Test public void allowsRight() { assertThat(track.allowsConnection(Direction.RIGHT)).isTrue(); }
@Test public void disallowsTop() { assertThat(track.allowsConnection(Direction.TOP)).isFalse(); }
@Test public void disallowsB... |
DefProConfiguration implements Configuration { @Override @SuppressWarnings("unchecked") public <T> T get(Property<T> property, T defaultValue) { Class<T> type = property.getType(); String key = property.getKey(); Object value; if (property instanceof ListProperty) { ListProperty listProperty = (ListProperty) property; ... | @Test public void getDefaultBooleanProperty() throws Exception { when(api.getBooleanValueOf(anyString())).thenThrow(new NotExistingVariableException("")); assertThat(config.get(new BooleanProperty("a", false))).isFalse(); }
@Test public void getDoubleProperty() throws Exception { when(api.getRealValueOf("a")).thenRetur... |
HorizontalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } boolean isConnected(); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Di... | @Test public void acceptsLeft() { assertThat(track.accepts(Direction.LEFT, marble)).isTrue(); }
@Test public void acceptsRight() { assertThat(track.accepts(Direction.RIGHT, marble)).isTrue(); }
@Test public void notAcceptsTop() { assertThat(track.accepts(Direction.TOP, marble)).isFalse(); }
@Test public void notAccepts... |
HorizontalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } boolean isConnected(); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction directio... | @Test public void passesMidpointLeft() { assertThat(track.passesMidpoint(Direction.LEFT, marble)).isTrue(); }
@Test public void passesMidpointRight() { assertThat(track.passesMidpoint(Direction.RIGHT, marble)).isTrue(); }
@Test public void passesMidpointTop() { assertThat(track.passesMidpoint(Direction.TOP, marble)).is... |
HorizontalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case LEFT: case RIGHT: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } boolean isConnect... | @Test public void acceptLeft() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.LEFT; track.addListener(listener); track.accept(direction, marble); verify(listener, times(1)).ballAccepted(track, direction, marble); }
@Test public vo... |
VerticalTrack extends Track { public boolean isConnected() { Tile tile = getTile(); if (tile == null) { throw new IllegalStateException("The track is not placed on a grid"); } Tile left = tile.get(Direction.TOP); Tile right = tile.get(Direction.BOTTOM); return left != null && right != null; } boolean isConnected(); @O... | @Test public void isNotConnected() { Grid grid = new Grid(null, 1, 1); grid.place(0, 0, track); assertThat(track.isConnected()).isFalse(); }
@Test public void isNotConnectedBottom() { Grid grid = new Grid(null, 1, 2); grid.place(0, 0, new VerticalTrack()); grid.place(0, 1, track); assertThat(track.isConnected()).isFals... |
VerticalTrack extends Track { @Override public boolean allowsConnection(Direction direction) { switch (direction) { case TOP: case BOTTOM: return true; default: return false; } } boolean isConnected(); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override boolean allowsConnection(Direction di... | @Test public void allowsTop() { assertThat(track.allowsConnection(Direction.TOP)).isTrue(); }
@Test public void allowsBottom() { assertThat(track.allowsConnection(Direction.BOTTOM)).isTrue(); }
@Test public void disallowsLeft() { assertThat(track.allowsConnection(Direction.LEFT)).isFalse(); }
@Test public void disallow... |
VerticalTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return allowsConnection(direction); } boolean isConnected(); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Dire... | @Test public void acceptsTop() { assertThat(track.accepts(Direction.TOP, marble)).isTrue(); }
@Test public void acceptsBottom() { assertThat(track.accepts(Direction.BOTTOM, marble)).isTrue(); }
@Test public void notAcceptsLeft() { assertThat(track.accepts(Direction.LEFT, marble)).isFalse(); }
@Test public void notAccep... |
VerticalTrack extends Track { @Override public boolean passesMidpoint(Direction direction, Marble marble) { return true; } boolean isConnected(); @Override boolean passesMidpoint(Direction direction, Marble marble); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction,... | @Test public void passesMidpointLeft() { assertThat(track.passesMidpoint(Direction.LEFT, marble)).isTrue(); }
@Test public void passesMidpointRight() { assertThat(track.passesMidpoint(Direction.RIGHT, marble)).isTrue(); }
@Test public void passesMidpointTop() { assertThat(track.passesMidpoint(Direction.TOP, marble)).is... |
VerticalTrack extends Track { @Override public void accept(Direction direction, Marble marble) { switch (direction) { case TOP: case BOTTOM: informAcceptation(direction, marble); break; default: throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } } boolean isConnected... | @Test public void acceptTop() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.TOP; track.addListener(listener); track.accept(direction, marble); verify(listener, times(1)).ballAccepted(track, direction, marble); }
@Test public void... |
FilterTrack extends Track implements TileableListener { @Override public boolean isConnected() { return track.isConnected(); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Overrid... | @Test public void isNotConnected() { Grid grid = new Grid(null, 1, 1); grid.place(0, 0, track); assertThat(track.isConnected()).isFalse(); }
@Test public void isConnected() { Grid grid = new Grid(null, 3, 1); grid.place(1, 0, track); assertThat(track.isConnected()).isTrue(); } |
FilterTrack extends Track implements TileableListener { @Override public boolean allowsConnection(Direction direction) { return track.allowsConnection(direction); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsCon... | @Test public void allowsLeft() { assertThat(track.allowsConnection(Direction.LEFT)).isTrue(); }
@Test public void allowsRight() { assertThat(track.allowsConnection(Direction.RIGHT)).isTrue(); }
@Test public void disallowsTop() { assertThat(track.allowsConnection(Direction.TOP)).isFalse(); }
@Test public void disallowsB... |
FilterTrack extends Track implements TileableListener { @Override public boolean accepts(Direction direction, Marble marble) { return track.accepts(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allo... | @Test public void acceptsRight() { assertThat(track.accepts(Direction.RIGHT, new Marble(MarbleType.GREEN))).isTrue(); }
@Test public void notAcceptsTop() { assertThat(track.accepts(Direction.TOP, new Marble(MarbleType.GREEN))).isFalse(); }
@Test public void notAcceptsBottom() { assertThat(track.accepts(Direction.BOTTOM... |
FilterTrack extends Track implements TileableListener { public Track getTrack() { return track; } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction d... | @Test public void getTrack() { assertThat(track.getTrack()).isEqualTo(inner); } |
FilterTrack extends Track implements TileableListener { public MarbleType getMarbleType() { return marbleType; } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean acce... | @Test public void getMarbleType() { assertThat(track.getMarbleType()).isEqualTo(type); } |
FilterTrack extends Track implements TileableListener { @Override public void ballDisposed(Tileable tileable, Direction direction, Marble marble) { informDispose(direction, marble); } FilterTrack(Track track, MarbleType marbleType); Track getTrack(); MarbleType getMarbleType(); @Override boolean isConnected(); @Overrid... | @Test public void informDispose() { Tileable tileable = new HorizontalTrack(); Direction direction = Direction.RIGHT; Marble marble = new Marble(MarbleType.BLUE); track.ballDisposed(tileable, direction, marble); } |
OneWayTrack extends Track { @Override public boolean isConnected() { return track.isConnected(); } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Over... | @Test public void isNotConnected() { Grid grid = new Grid(null, 1, 1); grid.place(0, 0, track); assertThat(track.isConnected()).isFalse(); }
@Test public void isConnected() { Grid grid = new Grid(null, 3, 1); grid.place(1, 0, track); assertThat(track.isConnected()).isTrue(); } |
OneWayTrack extends Track { @Override public boolean allowsConnection(Direction direction) { return this.track.allowsConnection(direction); } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Override boolean a... | @Test public void allowsLeft() { assertThat(track.allowsConnection(Direction.LEFT)).isTrue(); }
@Test public void allowsRight() { assertThat(track.allowsConnection(Direction.RIGHT)).isTrue(); }
@Test public void disallowsTop() { assertThat(track.allowsConnection(Direction.TOP)).isFalse(); }
@Test public void disallowsB... |
OneWayTrack extends Track { @Override public boolean accepts(Direction direction, Marble marble) { return this.track.accepts(direction, marble); } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Override bool... | @Test public void acceptsLeft() { assertThat(track.accepts(Direction.LEFT, new Marble(MarbleType.GREEN))).isTrue(); }
@Test public void notAcceptsTop() { assertThat(track.accepts(Direction.TOP, new Marble(MarbleType.GREEN))).isFalse(); }
@Test public void notAcceptsBottom() { assertThat(track.accepts(Direction.BOTTOM, ... |
OneWayTrack extends Track { @Override public void accept(Direction direction, Marble marble) { if (!accepts(direction, marble)) { throw new IllegalArgumentException("The track does not accept balls from the given " + "direction"); } informAcceptation(direction, marble); } OneWayTrack(Track track, Direction direction); ... | @Test public void acceptLeft() { TileableListener listener = mock(TileableListener.class); Marble marble = new Marble(MarbleType.BLUE); Direction direction = Direction.LEFT; track.addListener(listener); track.accept(direction, marble); verify(listener, times(1)).ballAccepted(track, direction, marble); }
@Test public vo... |
OneWayTrack extends Track { public Track getTrack() { return this.track; } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Dir... | @Test public void getTrack() { assertThat(track.getTrack()).isEqualTo(inner); } |
OneWayTrack extends Track { public Direction getDirection() { return direction; } OneWayTrack(Track track, Direction direction); Track getTrack(); Direction getDirection(); @Override void setTile(Tile tile); @Override boolean isConnected(); @Override boolean allowsConnection(Direction direction); @Override boolean acce... | @Test public void getDirection() { assertThat(track.getDirection()).isEqualTo(direction); } |
Marble implements Entity { public MarbleType getType() { return type; } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | @Test public void createPinkBall() { Marble marble = new Marble(MarbleType.PINK); assertThat(marble.getType()).isEqualTo(MarbleType.PINK); }
@Test public void createBlueBall() { Marble marble = new Marble(MarbleType.BLUE); assertThat(marble.getType()).isEqualTo(MarbleType.BLUE); }
@Test public void createGreenBall() { ... |
Marble implements Entity { public boolean isCompatible(Marble other) { return other != null && (type.equals(MarbleType.JOKER) || other.type.equals(MarbleType.JOKER) || type.equals(other.type)); } Marble(MarbleType type); MarbleType getType(); boolean isCompatible(Marble other); } | @Test public void isCompatibleSameColour() { Marble greenMarble1 = new Marble(MarbleType.GREEN); Marble greenMarble2 = new Marble(MarbleType.GREEN); assertThat(greenMarble1.isCompatible(greenMarble2)).isTrue(); }
@Test public void isIncompatibleDifferentColour() { Marble green = new Marble(MarbleType.GREEN); Marble blu... |
Empty extends Tileable { @Override public boolean accepts(Direction direction, Marble marble) { return false; } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void accept(Direction direction, Marble marble); } | @Test public void acceptsLeftFalse() { assertThat(empty.accepts(Direction.LEFT, marble)).isFalse(); }
@Test public void acceptsRightFalse() { assertThat(empty.accepts(Direction.RIGHT, marble)).isFalse(); }
@Test public void acceptsTopFalse() { assertThat(empty.accepts(Direction.TOP, marble)).isFalse(); }
@Test public v... |
Empty extends Tileable { @Override public void accept(Direction direction, Marble marble) { throw new IllegalArgumentException("An empty entity does not accept from any direction"); } @Override boolean allowsConnection(Direction direction); @Override boolean accepts(Direction direction, Marble marble); @Override void ... | @Test public void acceptLeftIllegalArgumentException() { assertThatThrownBy(() -> empty.accept(Direction.LEFT, null)).isInstanceOf(Exception.class); } |
SpawningNexus extends Nexus { public Marble spawn() { if (getContext().isOccupied()) { throw new IllegalStateException("The nexus is already occupied by a marble"); } Marble marble = new Marble(getContext().poll()); accept(direction, marble); getContext().setOccupied(true); return marble; } SpawningNexus(NexusContext c... | @Test public void spawnFailsOnOccupation() { context.setOccupied(true); assertThatThrownBy(() -> nexus.spawn()).isInstanceOf(IllegalStateException.class); }
@Test public void spawnInitialSequence() { assertThat(nexus.spawn().getType()).isEqualTo(MarbleType.BLUE); }
@Test public void peekInitialSequence() { assertThat(c... |
SpawningNexus extends Nexus { public Direction getDirection() { return direction; } SpawningNexus(NexusContext context, Direction direction); Marble spawn(); Direction getDirection(); static final Property<Double> JOKER_PROBABILITY; static final Property<List<String>> INITIAL_SEQUENCE; } | @Test public void getDirection() { assertThat(nexus.getDirection()).isEqualTo(direction); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.