当前位置: 首页>>代码示例>>Java>>正文


Java FeatureMatcher类代码示例

本文整理汇总了Java中org.hamcrest.FeatureMatcher的典型用法代码示例。如果您正苦于以下问题:Java FeatureMatcher类的具体用法?Java FeatureMatcher怎么用?Java FeatureMatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FeatureMatcher类属于org.hamcrest包,在下文中一共展示了FeatureMatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasBorderTitle

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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!
		}
	};
}
 
开发者ID:mmitch,项目名称:cgarbs-javalib-test,代码行数:25,代码来源:Swing.java

示例2: hasValue

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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!
		}
	};
}
 
开发者ID:mmitch,项目名称:cgarbs-javalib-test,代码行数:20,代码来源:Swing.java

示例3: hasContents

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
/**
 * 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;
        }
    };
}
 
开发者ID:asakusafw,项目名称:asakusafw-compiler,代码行数:21,代码来源:ResourceTestRoot.java

示例4: apiWithAcceptAsYaml

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
@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);
                }
            }
        }));
}
 
开发者ID:zalando-stups,项目名称:twintip-spring-web,代码行数:21,代码来源:SchemaResourceTest.java

示例5: hasMessage

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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);
    }
  };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:CompilerWarningIT.java

示例6: type

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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;
      }
    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:11,代码来源:ParameterSpecMatchers.java

示例7: name

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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;
      }
    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:11,代码来源:TypeSpecMatchers.java

示例8: superInterfaces

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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;
      }
    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:12,代码来源:TypeSpecMatchers.java

示例9: methods

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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;
      }
    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:12,代码来源:TypeSpecMatchers.java

示例10: fields

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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;
      }
    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:12,代码来源:TypeSpecMatchers.java

示例11: innerTypes

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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;
      }
    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:12,代码来源:TypeSpecMatchers.java

示例12: key

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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();
      }

    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:12,代码来源:EntryMatchers.java

示例13: fieldName

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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;
      }
    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:11,代码来源:FieldSpecMatchers.java

示例14: initializer

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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();
      }
    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:11,代码来源:FieldSpecMatchers.java

示例15: fieldType

import org.hamcrest.FeatureMatcher; //导入依赖的package包/类
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;
      }
    };
  }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:11,代码来源:FieldSpecMatchers.java


注:本文中的org.hamcrest.FeatureMatcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。