Java Code Examples for org.junit.Assert.assertThat()

The following are Jave code examples for showing how to use assertThat() of the org.junit.Assert class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-servicecomb-java-chassis   File: TestMicroserviceVersionMetaFactory.java   View Source Code Vote up 6 votes
@Test
public void create(@Mocked ConsumerSchemaFactory consumerSchemaFactory,
    @Mocked SchemaListenerManager schemaListenerManager) {
  String microserviceName = "app:ms";
  String microserviceId = "id";
  Microservice microservice = new Microservice();
  microservice.setVersion("1.0.0");

  new Expectations(RegistryUtils.class) {
    {
      RegistryUtils.getMicroservice(microserviceId);
      result = microservice;
    }
  };
  CseContext.getInstance().setConsumerSchemaFactory(consumerSchemaFactory);
  CseContext.getInstance().setSchemaListenerManager(schemaListenerManager);

  MicroserviceVersionMetaFactory factory = new MicroserviceVersionMetaFactory();
  MicroserviceVersion microserviceVersion = factory.create(microserviceName, microserviceId);
  Assert.assertThat(microserviceVersion, Matchers.instanceOf(MicroserviceVersionMeta.class));
}
 
Example 2
Project: spring-cloud-ribbon-extensions   File: PredicateBasedRuleSupportTest.java   View Source Code Vote up 5 votes
@Test
public void testSetPredicate() throws Exception {
    PredicateBasedRuleSupport support = new PredicateBasedRuleSupport();
    Assert.assertThat(support.getPredicate(), is(nullValue()));
    support.setPredicate(predicate);
    Assert.assertThat(support.getPredicate(), is(predicate));
}
 
Example 3
Project: incubator-servicecomb-java-chassis   File: TestCommonToHttpServletRequest.java   View Source Code Vote up 5 votes
@Test
public void testGetParameterValuesNormal() {
  Map<String, List<String>> queryParams = new HashMap<>();
  queryParams.put("name", Arrays.asList("value"));

  HttpServletRequest request = new CommonToHttpServletRequest(null, queryParams, null, null, false);
  Assert.assertThat(request.getParameterValues("name"), Matchers.arrayContaining("value"));
}
 
Example 4
Project: sf-java-ui   File: NumberFormTest.java   View Source Code Vote up 5 votes
@Test
public void testGenerate_Number_WithRightAddon() throws JsonProcessingException {
	UiForm ui = UiFormSchemaGenerator.get().generate(NumberFormRight.class);
	String json = new ObjectMapper().writeValueAsString(ui);
	//Assert.assertThat(json, hasJsonPath("$.schema.properties.number.title",equalTo("Number")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')]",hasSize(1)));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].description",hasItem("This is a number")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].placeholder",hasItem("Number of children")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].validationMessage",hasItem("this is a validation msg")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].type",hasItem("number")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].notitle",hasItem(true)));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].readonly",hasItem(true)));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].fieldAddonRight",hasItem("@")));

}
 
Example 5
Project: crnk-framework   File: DocumentMapperTest.java   View Source Code Vote up 5 votes
@Test
public void testAttributesBasic() {
	Task task = createTask(2, "sample task");

	Document document = mapper.toDocument(toResponse(task), createAdapter(Task.class));
	Resource resource = document.getSingleData().get();
	Assert.assertEquals("2", resource.getId());
	Assert.assertEquals("tasks", resource.getType());
	Assert.assertEquals("sample task", resource.getAttributes().get("name").asText());
	Assert.assertThat(resource.getAttributes().get("writeOnlyValue"), CoreMatchers.nullValue());
}
 
Example 6
Project: spring-cloud-ribbon-extensions   File: AbstractPreservesMessagePropertiesTest.java   View Source Code Vote up 5 votes
@Test
public void fail_on_get_property() throws Exception {
    when(message.getPropertyNames()).thenReturn(Collections.enumeration(asList("1", "2", "3")));
    when(message.getStringProperty("1")).thenReturn("1");
    when(message.getStringProperty("2")).thenThrow(JMSException.class);
    propagator.copyFromMessage(message);
    verify(message).getStringProperty(eq("1"));
    verify(message).getStringProperty(eq("2"));
    verify(message, never()).getStringProperty(eq("3"));
    Assert.assertThat(current().containsKey("1"), is(true));
    Assert.assertThat(current().entrySet().size(), is(1));
}
 
Example 7
Project: incubator-servicecomb-java-chassis   File: TestDynamicSchemaLoader.java   View Source Code Vote up 5 votes
@Test
public void testPutSelfBasePathIfAbsent_WithUrlPrefix() {
  System.setProperty(Const.URL_PREFIX, "/root/rest");
  microservice.setPaths(new ArrayList<>());

  loader.putSelfBasePathIfAbsent("perfClient", "/test");

  Assert.assertThat(microservice.getPaths().size(), Matchers.is(1));
  Assert.assertThat(microservice.getPaths().get(0).getPath(), Matchers.is("/root/rest/test"));

  System.clearProperty(Const.URL_PREFIX);
}
 
Example 8
Project: db-queue   File: QueueActorDaoTest.java   View Source Code Vote up 5 votes
@Test
public void reenqueue_should_return_false_when_no_update() throws Exception {
    QueueLocation location = generateUniqueLocation();
    Boolean reenqueueResult = executeInTransaction(() ->
            queueActorDao.reenqueue(location, "...", Duration.ofHours(1L)));
    Assert.assertThat(reenqueueResult, equalTo(false));
}
 
Example 9
Project: incubator-servicecomb-java-chassis   File: TestAbstractHttpServletRequest.java   View Source Code Vote up 5 votes
@Test
public void testAttribute() {
  String key = "a1";
  String value = "abc";
  request.setAttribute(key, value);
  Assert.assertSame(value, request.getAttribute(key));
  Assert.assertThat(Collections.list(request.getAttributeNames()), Matchers.contains(key));

  request.setAttribute("a2", "v");
  Assert.assertThat(Collections.list(request.getAttributeNames()), Matchers.contains(key, "a2"));

  request.removeAttribute(key);
  Assert.assertNull(request.getAttribute(key));
}
 
Example 10
Project: javaOIDCMsg   File: JWTDecoderTest.java   View Source Code Vote up 5 votes
@Test
public void shouldGetCustomMapClaim() throws Exception {
    String token = "eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjp7InN0cmluZyI6InZhbHVlIiwibnVtYmVyIjoxLCJib29sZWFuIjp0cnVlfX0.-8aIaXd2-rp1lLuDEQmCeisCBX9X_zbqdPn2llGxNoc";
    JWT jwt = JWT.require(Algorithm.HMAC256("secret")).build();
    DecodedJWT decodedJWT = jwt.decode(token);
    Assert.assertThat(decodedJWT, is(notNullValue()));
    Map<String, Object> map = decodedJWT.getClaim("name").asMap();
    Assert.assertThat(map, hasEntry("string", (Object) "value"));
    Assert.assertThat(map, hasEntry("number", (Object) 1));
    Assert.assertThat(map, hasEntry("boolean", (Object) true));
}
 
Example 11
Project: incubator-servicecomb-java-chassis   File: TestVertxServerRequestToHttpServletRequest.java   View Source Code Vote up 5 votes
@Test
public void testGetHeaderNames() {
  MultiMap headers = MultiMap.caseInsensitiveMultiMap();
  headers.add("name", "value");
  new Expectations() {
    {
      vertxRequest.headers();
      result = headers;
    }
  };

  Assert.assertThat(Collections.list(request.getHeaderNames()), Matchers.contains("name"));

}
 
Example 12
Project: randomito-all   File: MinMaxAnnotationPostProcessorTest.java   View Source Code Vote up 5 votes
@Test
public void testIgnored() {
    // given
    Wrapper wrapper = new Wrapper();

    // when
    Integer minMax = postprocess(wrapper, "ignored", Integer.class);

    // then
    Assert.assertThat(minMax, CoreMatchers.is(0));
}
 
Example 13
Project: randomito-all   File: DigitsAnnotationPostProcessorTest.java   View Source Code Vote up 5 votes
@Test
public void testNoAnnotation() {
    // given
    Wrapper wrapper = new Wrapper();

    // when
    Float retVal = postprocess(wrapper, "aFloat", Float.class);

    // then
    Assert.assertThat(retVal, is(0f));
}
 
Example 14
Project: summer-mqtt   File: TopicSubscriptionTest.java   View Source Code Vote up 5 votes
@Test
public void testClone()
{
    TopicSubscription topic = new TopicSubscription(TOPIC_FILTER, MqttQualityOfService.QOS_0);
    TopicSubscription clone = topic.clone();
    Assert.assertEquals(topic.getTopicFilter(), clone.getTopicFilter());
    Assert.assertEquals(topic.getQualityOfService(), clone.getQualityOfService());
    Assert.assertThat(topic.isSubscribed(), Is.is(CoreMatchers.equalTo(clone.isSubscribed())));
    topic.setSubscribed(true);
    Assert.assertThat(topic.isSubscribed(), Is.is(CoreMatchers.not(clone.isSubscribed())));
    clone = topic.clone();
    Assert.assertEquals(topic.getTopicFilter(), clone.getTopicFilter());
    Assert.assertEquals(topic.getQualityOfService(), clone.getQualityOfService());
    Assert.assertThat(topic.isSubscribed(), Is.is(CoreMatchers.equalTo(clone.isSubscribed())));
}
 
Example 15
Project: randomito-all   File: MinMaxAnnotationPostProcessorTest.java   View Source Code Vote up 5 votes
@Test
public void testMinMaxOnStringAnnotation() {
    // given
    Wrapper wrapper = new Wrapper();
    wrapper.string = "abcdefghijklmon.......";

    // when
    String minMax = postprocess(wrapper, "string", String.class);

    // then
    Assert.assertThat(minMax.length(), OrderingComparison.greaterThan(2));
    Assert.assertThat(minMax.length(), OrderingComparison.lessThanOrEqualTo(5));
}
 
Example 16
Project: satisfy   File: InboxMessagesInspectorPOP3.java   View Source Code Vote up 4 votes
@Override
public void verifyInboxContainsMatchingLetter(String sender, String subject, String body) throws IOException, MessagingException {
    List<MessageBean> matchingLetters = EmailHelper.getLettersThatMatchesParameters(sender, subject, body, EmailHelper.getInboxFolder(getPop3Properties()));
    Assert.assertThat(matchingLetters, is(not(empty())));
}
 
Example 17
Project: incubator-servicecomb-java-chassis   File: TestPartPropertyCreator.java   View Source Code Vote up 4 votes
@SuppressWarnings("unchecked")
@Test
public void classes() {
  Assert.assertThat(creator.classes(), Matchers.arrayContaining(Part.class));
}
 
Example 18
Project: rskj   File: LockWhitelistTest.java   View Source Code Vote up 4 votes
@Test
public void getAddresses() {
    Assert.assertNotSame(whitelist.getAddresses(), addresses);
    Assert.assertThat(whitelist.getAddresses(), containsInAnyOrder(addresses.keySet().toArray()));
}
 
Example 19
Project: incubator-servicecomb-java-chassis   File: TestJaxrsProducerResponseMapperFactory.java   View Source Code Vote up 4 votes
@Test
public void createResponseMapper() {
  Assert.assertThat(factory.createResponseMapper(null, null, null),
      Matchers.instanceOf(JaxrsProducerResponseMapper.class));
}
 
Example 20
Project: wulkanowy   File: VulcanTest.java   View Source Code Vote up 4 votes
@Test
public void getNotesListTest() throws Exception {
    Mockito.when(vulcan.getNotesList()).thenCallRealMethod();
    Assert.assertThat(vulcan.getNotesList(),
            CoreMatchers.instanceOf(NotesList.class));
}