java类org.hamcrest.FeatureMatcher的实例源码

Swing.java 文件源码 项目:cgarbs-javalib-test 阅读 25 收藏 0 点赞 0 评论 0
public static Matcher<Component> hasBorderTitle(final Matcher<String> m)
{
    return new FeatureMatcher<Component, String>(m, "title", "title") {

        @Override
        protected String featureValueOf(Component actual)
        {
            if (actual instanceof JPanel)
            {
                Border border = ((JPanel) actual).getBorder();
                if (border == null)
                {
                    return null;
                }
                if (border instanceof TitledBorder)
                {
                    return ((TitledBorder) border).getTitle();
                }
                return "BORDER CLASS " + border.getClass() + " DOES NOT WORK HERE"; // fixme: stupid!
            }
            return "CLASS " + actual.getClass() + " DOES NOT WORK HERE"; // fixme: stupid!
        }
    };
}
Swing.java 文件源码 项目:cgarbs-javalib-test 阅读 23 收藏 0 点赞 0 评论 0
public static Matcher<Component> hasValue(final Matcher<String> m)
{
    return new FeatureMatcher<Component, String>(m, "value", "value") {

        @Override
        protected String featureValueOf(Component actual)
        {
            if (actual instanceof JTextField)
            {
                return ((JTextField) actual).getText();
            }
            if (actual instanceof JLabel)
            {
                return ((JLabel) actual).getText();
            }
            return "CLASS " + actual.getClass() + " DOES NOT WORK HERE"; // fixme: stupid!
        }
    };
}
ResourceTestRoot.java 文件源码 项目:asakusafw-compiler 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Returns a matcher whether the item has the specified contents or not.
 * @param value the expected contents
 * @return the matcher
 */
public static Matcher<ResourceItem> hasContents(String value) {
    return new FeatureMatcher<ResourceItem, String>(is(value), "has contents", "hasContents") {
        @Override
        protected String featureValueOf(ResourceItem actual) {
            String contents = contents(actual);
            try {
                String provider = new String(dump(actual), ENCODING);
                assertThat(provider, is(contents));
            } catch (IOException e) {
                throw new AssertionError(e);
            }
            return contents;
        }
    };
}
SchemaResourceTest.java 文件源码 项目:twintip-spring-web 阅读 25 收藏 0 点赞 0 评论 0
@Test
public void apiWithAcceptAsYaml() throws Exception {
    final MediaType yaml = MediaType.parseMediaType("application/yaml");
    final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
    final JsonNode expected = mapper.readTree(yamlResource.getInputStream());

    mvc.perform(request(HttpMethod.GET, API_PATH)
        .accept(yaml))
        .andExpect(content().contentType(yaml))
        .andExpect(content().string(new FeatureMatcher<String, JsonNode>(equalTo(expected), "yaml", "yaml") {
            @Override
            protected JsonNode featureValueOf(String actual) {
                try {
                    return mapper.readTree(actual);
                } catch (IOException e) {
                    throw new AssertionError(e);
                }
            }
        }));
}
CompilerWarningIT.java 文件源码 项目:GitHub 阅读 26 收藏 0 点赞 0 评论 0
public static Matcher<Diagnostic<? extends JavaFileObject>> hasMessage( Matcher<String> messageMatcher ) {
  return new FeatureMatcher<Diagnostic<? extends JavaFileObject>, String>(messageMatcher, "message", "message") {
    @Override
    protected String featureValueOf(Diagnostic<? extends JavaFileObject> actual) {
      return actual.getMessage(Locale.ENGLISH);
    }
  };
}
ParameterSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 33 收藏 0 点赞 0 评论 0
public static <Q extends TypeName> Matcher<ParameterSpec> type(Matcher<Q> match) {

    return new FeatureMatcher<ParameterSpec, Q>(match, "type name", "type name") {

      @Override
      protected Q featureValueOf(ParameterSpec actual) {
        return (Q) actual.type;
      }
    };
  }
TypeSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 25 收藏 0 点赞 0 评论 0
public static Matcher<TypeSpec> name(Matcher<String> match) {

    return new FeatureMatcher<TypeSpec, String>(match, "type name", "type name") {

      @Override
      protected String featureValueOf(TypeSpec actual) {
        return actual.name;
      }
    };
  }
TypeSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 46 收藏 0 点赞 0 评论 0
public static Matcher<TypeSpec> superInterfaces(Matcher<Iterable<? extends TypeName>> memberMatcher) {

    return new FeatureMatcher<TypeSpec, Iterable<? extends TypeName>>(memberMatcher, "super interfaces", "super interfaces") {

      @Override
      protected Iterable<? extends TypeName> featureValueOf(TypeSpec actual) {

        return actual.superinterfaces;
      }
    };
  }
TypeSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 33 收藏 0 点赞 0 评论 0
public static Matcher<TypeSpec> methods(Matcher<Iterable<? extends MethodSpec>> memberMatcher) {

    return new FeatureMatcher<TypeSpec, Iterable<? extends MethodSpec>>(memberMatcher, "method", "method") {

      @Override
      protected Iterable<? extends MethodSpec> featureValueOf(TypeSpec actual) {

        return actual.methodSpecs;
      }
    };
  }
TypeSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 28 收藏 0 点赞 0 评论 0
public static Matcher<TypeSpec> fields(Matcher<Iterable<? extends FieldSpec>> memberMatcher) {

    return new FeatureMatcher<TypeSpec, Iterable<? extends FieldSpec>>(memberMatcher, "field", "field") {

      @Override
      protected Iterable<? extends FieldSpec> featureValueOf(TypeSpec actual) {

        return actual.fieldSpecs;
      }
    };
  }
TypeSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 20 收藏 0 点赞 0 评论 0
public static Matcher<TypeSpec> innerTypes(Matcher<Iterable<? extends TypeSpec>> typeMatcher) {

    return new FeatureMatcher<TypeSpec, Iterable<? extends TypeSpec>>(typeMatcher, "inner type", "inner type") {

      @Override
      protected Iterable<? extends TypeSpec> featureValueOf(TypeSpec actual) {

        return actual.typeSpecs;
      }
    };
  }
EntryMatchers.java 文件源码 项目:raml-java-tools 阅读 25 收藏 0 点赞 0 评论 0
public static Matcher<Map.Entry<?, ?>> key(Matcher<?> matcher) {

    return new FeatureMatcher<Map.Entry<?, ?>, Object>((Matcher<? super Object>) matcher, "key", "key") {

      @Override
      protected Object featureValueOf(Map.Entry<?, ?> actual) {
        return actual.getKey();
      }

    };
  }
FieldSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 25 收藏 0 点赞 0 评论 0
public static Matcher<FieldSpec> fieldName(Matcher<String> match) {

    return new FeatureMatcher<FieldSpec, String>(match, "field name", "field name") {

      @Override
      protected String featureValueOf(FieldSpec actual) {
        return actual.name;
      }
    };
  }
FieldSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 40 收藏 0 点赞 0 评论 0
public static Matcher<FieldSpec> initializer(Matcher<String> match) {

    return new FeatureMatcher<FieldSpec, String>(match, "field initializer", "field initializer") {

      @Override
      protected String featureValueOf(FieldSpec actual) {
        return actual.initializer.toString();
      }
    };
  }
FieldSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 41 收藏 0 点赞 0 评论 0
public static <T extends TypeName> Matcher<FieldSpec> fieldType(Matcher<T> match) {

    return new FeatureMatcher<FieldSpec, T>(match, "type name", "type name") {

      @Override
      protected T featureValueOf(FieldSpec actual) {
        return (T) actual.type;
      }
    };
  }
MethodSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 25 收藏 0 点赞 0 评论 0
public static Matcher<MethodSpec> methodName(Matcher<String> match) {

    return new FeatureMatcher<MethodSpec, String>(match, "method name", "method name") {

      @Override
      protected String featureValueOf(MethodSpec actual) {
        return actual.name;
      }
    };
  }
MethodSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 29 收藏 0 点赞 0 评论 0
public static<K extends TypeName> Matcher<MethodSpec> returnType(Matcher<K> match) {

    return new FeatureMatcher<MethodSpec, K>(match, "return type", "return type") {

      @Override
      protected K featureValueOf(MethodSpec actual) {
        return (K)actual.returnType;
      }
    };
  }
MethodSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 28 收藏 0 点赞 0 评论 0
public static Matcher<MethodSpec> codeContent(Matcher<String> match) {

    return new FeatureMatcher<MethodSpec, String>(match, "method content", "method content") {

      @Override
      protected String featureValueOf(MethodSpec actual) {
        return actual.code.toString();
      }
    };
  }
MethodSpecMatchers.java 文件源码 项目:raml-java-tools 阅读 26 收藏 0 点赞 0 评论 0
public static Matcher<MethodSpec> parameters(Matcher<Iterable<? extends ParameterSpec>> memberMatcher) {

    return new FeatureMatcher<MethodSpec, Iterable<? extends ParameterSpec>>(memberMatcher, "parameter", "parameter") {

      @Override
      protected Iterable<? extends ParameterSpec> featureValueOf(MethodSpec actual) {

        return actual.parameters;
      }
    };
  }
HotaruLexerTest.java 文件源码 项目:HotaruFX 阅读 28 收藏 0 点赞 0 评论 0
Matcher<Token> tokenId(Matcher<HotaruTokenId> matcher) {
    return new FeatureMatcher<Token, HotaruTokenId>(matcher, "tokenId", "tokenId") {

        @Override
        protected HotaruTokenId featureValueOf(Token actual) {
            return actual.getType();
        }
    };
}
Proposals.java 文件源码 项目:spring-cloud-dashboard 阅读 23 收藏 0 点赞 0 评论 0
static org.hamcrest.Matcher<CompletionProposal> proposalThat(org.hamcrest.Matcher<String> matcher) {
    return new FeatureMatcher<CompletionProposal, String>(matcher, "a proposal whose text", "text") {
        @Override
        protected String featureValueOf(CompletionProposal actual) {
            return actual.getText();
        }
    };
}
MobileAnnouncementFeatureTest.java 文件源码 项目:oma-riista-web 阅读 25 收藏 0 点赞 0 评论 0
private static Matcher<MobileAnnouncementDTO> hasAnnouncementBody(Matcher<String> childMatcher) {
    return new FeatureMatcher<MobileAnnouncementDTO, String>(childMatcher, "body", "body") {
        @Override
        protected String featureValueOf(MobileAnnouncementDTO actual) {
            return actual.getBody();
        }
    };
}
MobileAnnouncementFeatureTest.java 文件源码 项目:oma-riista-web 阅读 34 收藏 0 点赞 0 评论 0
private static Matcher<MobileAnnouncementDTO> hasAnnouncementSubject(Matcher<String> childMatcher) {
    return new FeatureMatcher<MobileAnnouncementDTO, String>(childMatcher, "subject", "subject") {
        @Override
        protected String featureValueOf(MobileAnnouncementDTO actual) {
            return actual.getSubject();
        }
    };
}
MobileAnnouncementFeatureTest.java 文件源码 项目:oma-riista-web 阅读 26 收藏 0 点赞 0 评论 0
private static Matcher<MobileAnnouncementDTO> hasAnnouncementId(Matcher<Long> childMatcher) {
    return new FeatureMatcher<MobileAnnouncementDTO, Long>(childMatcher, "id", "id") {
        @Override
        protected Long featureValueOf(MobileAnnouncementDTO actual) {
            return actual.getId();
        }
    };
}
AnnouncementMatcher.java 文件源码 项目:oma-riista-web 阅读 27 收藏 0 点赞 0 评论 0
public static FeatureMatcher<ListAnnouncementDTO, String> hasBody(final String expected) {
    return new FeatureMatcher<ListAnnouncementDTO, String>(equalTo(expected), "body", "body") {
        @Override
        protected String featureValueOf(final ListAnnouncementDTO announcement) {
            return announcement.getBody();
        }
    };
}
AnnouncementMatcher.java 文件源码 项目:oma-riista-web 阅读 101 收藏 0 点赞 0 评论 0
public static FeatureMatcher<ListAnnouncementDTO, String> hasSubject(final String expected) {
    return new FeatureMatcher<ListAnnouncementDTO, String>(equalTo(expected), "subject", "subject") {
        @Override
        protected String featureValueOf(final ListAnnouncementDTO announcement) {
            return announcement.getSubject();
        }
    };
}
AnnouncementMatcher.java 文件源码 项目:oma-riista-web 阅读 37 收藏 0 点赞 0 评论 0
public static FeatureMatcher<ListAnnouncementDTO, AnnouncementSenderType> hasSenderType(final AnnouncementSenderType expected) {
    return new FeatureMatcher<ListAnnouncementDTO, AnnouncementSenderType>(equalTo(expected), "senderType", "senderType") {
        @Override
        protected AnnouncementSenderType featureValueOf(final ListAnnouncementDTO announcement) {
            return announcement.getSenderType();
        }
    };
}
AnnouncementMatcher.java 文件源码 项目:oma-riista-web 阅读 26 收藏 0 点赞 0 评论 0
public static FeatureMatcher<ListAnnouncementDTO, Map<String, String>> hasFromOrganisation(final Organisation expected) {
    return new FeatureMatcher<ListAnnouncementDTO, Map<String, String>>(equalTo(expected.getNameLocalisation().asMap()), "fromOrganisation", "fromOrganisation") {
        @Override
        protected Map<String, String> featureValueOf(final ListAnnouncementDTO announcement) {
            return announcement.getFromOrganisation().getName();
        }
    };
}
OccupationMatchers.java 文件源码 项目:oma-riista-web 阅读 32 收藏 0 点赞 0 评论 0
public static Matcher<Occupation> hasOccupationType(final Matcher<OccupationType> childMatcher) {
    return new FeatureMatcher<Occupation, OccupationType>(childMatcher, "occupationType", "occupationType") {
        @Override
        protected OccupationType featureValueOf(Occupation actual) {
            return actual.getOccupationType();
        }
    };
}
OccupationMatchers.java 文件源码 项目:oma-riista-web 阅读 23 收藏 0 点赞 0 评论 0
public static Matcher<Occupation> hasPersonId(final Matcher<Long> childMatcher) {
    return new FeatureMatcher<Occupation, Long>(childMatcher, "personId", "personId") {
        @Override
        protected Long featureValueOf(Occupation actual) {
            return F.getId(actual.getPerson());
        }
    };
}


问题


面经


文章

微信
公众号

扫码关注公众号