Java 类org.hamcrest.core.IsNull 实例源码

项目:droidcon2016    文件:RedditListViewModelTest.java   
@Test
public void refresh() throws Exception {
    final Reddit reddit = new Reddit();
    PublishSubject<Reddit> subject = PublishSubject.create();
    Mockito.doReturn(subject.asObservable().toList())
            .when(mRepository)
            .getReddits(Mockito.anyString());
    mViewModel.refresh();
    Mockito.verify(mRepository).getReddits("test");
    Assert.assertThat(mViewModel.errorText.get(), IsNull.nullValue());
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(true));
    subject.onNext(reddit);
    subject.onCompleted();
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(false));
    Assert.assertThat(mViewModel.reddits, IsCollectionContaining.hasItems(reddit));
}
项目:elasticsearch_my    文件:AnalyzeActionIT.java   
public void testCustomCharFilterInRequest() throws Exception {
    Map<String, Object> charFilterSettings = new HashMap<>();
    charFilterSettings.put("type", "mapping");
    charFilterSettings.put("mappings", new String[]{"ph => f", "qu => q"});
    AnalyzeResponse analyzeResponse = client().admin().indices()
        .prepareAnalyze()
        .setText("jeff quit phish")
        .setTokenizer("keyword")
        .addCharFilter(charFilterSettings)
        .setExplain(true)
        .get();

    assertThat(analyzeResponse.detail().analyzer(), IsNull.nullValue());
    //charfilters
    assertThat(analyzeResponse.detail().charfilters().length, equalTo(1));
    assertThat(analyzeResponse.detail().charfilters()[0].getName(), equalTo("_anonymous_charfilter_[0]"));
    assertThat(analyzeResponse.detail().charfilters()[0].getTexts().length, equalTo(1));
    assertThat(analyzeResponse.detail().charfilters()[0].getTexts()[0], equalTo("jeff qit fish"));
    //tokenizer
    assertThat(analyzeResponse.detail().tokenizer().getName(), equalTo("keyword"));
    assertThat(analyzeResponse.detail().tokenizer().getTokens().length, equalTo(1));
    assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getTerm(), equalTo("jeff qit fish"));
    assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getStartOffset(), equalTo(0));
    assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getEndOffset(), equalTo(15));
    assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getPositionLength(), equalTo(1));
}
项目:droidcon2016    文件:RedditListViewModelTest.java   
@Test
public void refreshError() throws Exception {
    PublishSubject<Reddit> subject = PublishSubject.create();
    Mockito.doReturn(subject.asObservable().toList())
            .when(mRepository)
            .getReddits(Mockito.anyString());
    mViewModel.refresh();
    Mockito.verify(mRepository).getReddits("test");
    Assert.assertThat(mViewModel.errorText.get(), IsNull.nullValue());
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(true));
    subject.onError(new Exception("error text"));
    Assert.assertThat(mViewModel.isLoading.get(), Is.is(false));
    Assert.assertThat(mViewModel.errorText.get(), IsEqual.equalTo("error text"));
}
项目:easyrec_major    文件:ClusterServiceTest.java   
@Test
public void testRenameCluster() {
     Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
     ClusterVO root = clusters.getRoot();
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
    assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.nullValue());
     try {
        clusterService.renameCluster(1, "CLUSTER1", "CLUSTER3");
     } catch (ClusterException ce) {
         logger.info(ce);
     }
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
     assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.notNullValue());
}
项目:maven-confluence-plugin    文件:SiteTest.java   
@Test
public void shouldSupportImgRefLink() throws IOException {
    final InputStream stream = getClass().getClassLoader().getResourceAsStream("withImgRefLink.md");
    assertThat( stream, IsNull.notNullValue());
    final InputStream inputStream = Site.processMarkdown(stream, "Test IMG");
    assertThat( inputStream, IsNull.notNullValue());
    final String converted = IOUtils.toString(inputStream);

    assertThat(converted, containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|alt=\"conf-icon\"|title=\"My conf-icon\"!"));
    assertThat(converted, containsString("!conf-icon-64.png|alt=\"conf-icon\"|title=\"My conf-icon\"!"));
    assertThat(converted, containsString("!conf-icon-64.png|alt=\"conf-icon\"!"));
    assertThat(converted, containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|alt=\"conf-icon-y\"|title=\"My conf-icon\"!"));
    assertThat(converted, containsString("!http://www.lewe.com/wp-content/uploads/2016/03/conf-icon-64.png|alt=\"conf-icon-y1\"!"));
    assertThat(converted, containsString("!conf-icon-64.png|alt=\"conf-icon-y2\"!"));
    assertThat(converted, containsString("!conf-icon-64.png|alt=\"conf-icon-none\"!"));
}
项目:maven-confluence-plugin    文件:SiteTest.java   
@Test
public void shouldSupportSimpleNode() throws IOException {
    final InputStream stream = getClass().getClassLoader().getResourceAsStream("simpleNodes.md");
    assertThat( stream, IsNull.notNullValue());
    final InputStream inputStream = Site.processMarkdown(stream, "Test");
    assertThat( inputStream, IsNull.notNullValue());
    final String converted = IOUtils.toString(inputStream);

    assertThat("All forms of HRules should be supported", converted, containsString("----\n1\n----\n2\n----\n3\n----\n4\n----"));
    /* only when Extensions.SMARTS is activated
    assertThat(converted, containsString("&hellip;"));
    assertThat(converted, containsString("&ndash;"));
    assertThat(converted, containsString("&mdash;"));
    */
    assertThat(converted, containsString("Forcing a line-break\nNext line in the list"));
    assertThat(converted, containsString("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"));
}
项目:maven-confluence-plugin    文件:SiteTest.java   
@Test
public void shouldCreateSpecificNoticeBlock() throws IOException {
    final InputStream stream = getClass().getClassLoader().getResourceAsStream("createSpecificNoticeBlock.md");
    assertThat( stream, IsNull.notNullValue());
    final InputStream inputStream = Site.processMarkdown(stream, "Test Macro");
    assertThat( inputStream, IsNull.notNullValue());
    final String converted = IOUtils.toString(inputStream);

    assertThat(converted, containsString("{info:title=About me}\n"));
    assertThat("Should not generate unneeded param 'title'", converted, not(containsString("{note:title=}\n")));
    assertThat(converted, containsString("{tip:title=About you}\n"));
    assertThat(converted, containsString("bq. test a simple blockquote"));
    assertThat(converted, containsString("{quote}\n"));
    assertThat(converted, containsString("* one\n* two"));
    assertThat(converted, containsString("a *strong* and _pure_ feeling"));

}
项目:maven-confluence-plugin    文件:Issue130IntegrationTest.java   
@Before
@Override
public void initService() throws Exception {

    super.initService();


    try {
        // SSL Implementation
        final SSLSocketFactory sslSocketFactory = SSLFactories.newInstance( new YesTrustManager());
        Assert.assertThat(sslSocketFactory, IsNull.notNullValue());

        final X509TrustManager trustManager = new YesTrustManager();
        final HostnameVerifier hostnameVerifier = new YesHostnameVerifier();

        service.client
                .hostnameVerifier(hostnameVerifier)
                .sslSocketFactory(sslSocketFactory, trustManager)
                ;

    } catch (Exception ex) {
        throw new IllegalStateException(ex);
    }
}
项目:DeviceConnect-Android    文件:FailAuthorizationProfileTestCase.java   
/**
 * clientIdを作成する.
 * @return clientId
 * @throws Exception clientIdの作成に失敗した場合に発生
 */
private String createClientId() throws Exception {
    String uri = "http://localhost:4035/gotapi/authorization/grant";

    Map<String, String> headers = new HashMap<>();
    headers.put("Origin", getOrigin());

    HttpUtil.Response response = HttpUtil.get(uri, headers);
    assertThat(response, is(notNullValue()));

    JSONObject json = response.getJSONObject();
    assertThat(json, is(notNullValue()));
    assertThat(json.getInt("result"), is(0));
    assertThat(json.getString("clientId"), is(IsNull.notNullValue()));

    return json.getString("clientId");
}
项目:spring-streaming-processing    文件:BuyOrderServiceActivatorTest.java   
@Test
public void buyOrderOfCustomerWithEnoughCashAndKnownStock() {
    Mockito.when(stockRepository.findOneByName(Matchers.anyString())).thenReturn(Optional.of(new Stock("TSLA", 10)));
    Mockito.when(customerRepository.findOne(Matchers.anyLong())).thenReturn(new Customer("Test user", 500));

    BuyOrder optional = buyOrderServiceActivator.processOrder(new BuyOrder("TSLA", 10, 1));
    assertThat(optional, is(IsNull.notNullValue()));

    Mockito.verify(stockRepository).findOneByName("TSLA");
    Mockito.verify(customerRepository).findOne(1L);

    ArgumentCaptor<Customer> customerArgumentCaptor = ArgumentCaptor.forClass(Customer.class);
    Mockito.verify(customerRepository).save(customerArgumentCaptor.capture());

    Customer customer = customerArgumentCaptor.getValue();
    assertThat(customer.getFreeCash(), is(400));
    assertThat(customer.getName(), is("Test user"));
    Mockito.verifyNoMoreInteractions(customerRepository, stockRepository);
}
项目:easyrec-PoC    文件:ClusterServiceTest.java   
@Test
public void testRenameCluster() {
     Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
     ClusterVO root = clusters.getRoot();
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
    assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.nullValue());
     try {
        clusterService.renameCluster(1, "CLUSTER1", "CLUSTER3");
     } catch (ClusterException ce) {
         logger.info(ce);
     }
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
     assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.notNullValue());
}
项目:c5    文件:HRegionBridgeTest.java   
@Test
public void shouldEasilyDoSimpleAtomicMutationMulti() throws Exception {
  ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
  RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
      regionLocation);

  context.checking(new Expectations() {
    {
      oneOf(hRegionInterface).processRowsWithLocks(with(any(MultiRowMutationProcessor.class)));
    }
  });

  MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow")));

  RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
      true,
      Arrays.asList(new Action(0, mutation, null))));
  assertThat(actions.getException(), IsNull.nullValue());
  assertThat(actions.getResultOrExceptionList().size(), is(1));
}
项目:c5    文件:HRegionBridgeTest.java   
@Test
public void shouldEasilyDoAtomicMutationOnlyMultiPut() throws Exception {
  ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
  RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
      regionLocation);

  context.checking(new Expectations() {
    {
      oneOf(hRegionInterface).processRowsWithLocks(with(any(MultiRowMutationProcessor.class)));
    }
  });

  MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow")));

  RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
      true,
      Arrays.asList(
          new Action(0, mutation, null),
          new Action(1, mutation, null),
          new Action(2, mutation, null))
  ));
  assertThat(actions.getException(), IsNull.nullValue());
  assertThat(actions.getResultOrExceptionList().size(), is(3));
}
项目:c5    文件:HRegionBridgeTest.java   
@Test
public void shouldEasilyDoAtomicMutationOnlyMultiDelete() throws Exception {
  ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
  RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
      regionLocation);

  context.checking(new Expectations() {
    {
      oneOf(hRegionInterface).processRowsWithLocks(with(any(MultiRowMutationProcessor.class)));
    }
  });

  MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.DELETE, new Delete(Bytes.toBytes("fakeRow")));

  RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
      true,
      Arrays.asList(
          new Action(0, mutation, null),
          new Action(1, mutation, null),
          new Action(2, mutation, null))
  ));
  assertThat(actions.getException(), IsNull.nullValue());
  assertThat(actions.getResultOrExceptionList().size(), is(3));
}
项目:c5    文件:HRegionBridgeTest.java   
@Test
public void shouldFailWhenWeTryToAtomicMutateAndGet() throws Exception {
  ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
  RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
      regionLocation);

  MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.DELETE, new Delete(Bytes.toBytes("fakeRow")));
  Get get = ProtobufUtil.toGet(new org.apache.hadoop.hbase.client.Get(Bytes.toBytes("fakeRow2")), false);
  Get exists = ProtobufUtil.toGet(new org.apache.hadoop.hbase.client.Get(Bytes.toBytes("fakeRow2")), true);

  RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
      true,
      Arrays.asList(
          new Action(0, mutation, get),
          new Action(1, mutation, exists))
  ));
  assertThat(actions.getException(), IsNull.notNullValue());
  assertThat(actions.getResultOrExceptionList().size(), is(0));
}
项目:c5    文件:HRegionBridgeTest.java   
@Test
public void shouldEasilyDoSimpleMutationMulti() throws Exception {
  ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
  RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
      regionLocation);

  context.checking(new Expectations() {
    {
      oneOf(hRegionInterface).put(with(any(Put.class)));
    }
  });

  MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow")));

  RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
      false,
      Arrays.asList(new Action(0, mutation, null))));
  assertThat(actions.getException(), IsNull.nullValue());
  assertThat(actions.getResultOrExceptionList().size(), is(1));
}
项目:c5    文件:HRegionBridgeTest.java   
@Test
public void shouldEasilyDoMutationOnlyMultiPut() throws Exception {
  ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
  RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
      regionLocation);

  context.checking(new Expectations() {
    {
      exactly(3).of(hRegionInterface).put(with(any(Put.class)));
    }
  });

  MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow")));
  RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
      false,
      Arrays.asList(
          new Action(0, mutation, null),
          new Action(1, mutation, null),
          new Action(2, mutation, null))
  ));
  assertThat(actions.getException(), IsNull.nullValue());
  assertThat(actions.getResultOrExceptionList().size(), is(3));
}
项目:c5    文件:HRegionBridgeTest.java   
@Test
public void shouldEasilyDoMutationOnlyMultiDelete() throws Exception {
  ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
  RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
      regionLocation);

  context.checking(new Expectations() {
    {
      oneOf(hRegionInterface).delete(with(any(Delete.class)));
      oneOf(hRegionInterface).delete(with(any(Delete.class)));
      oneOf(hRegionInterface).delete(with(any(Delete.class)));
    }
  });

  MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.DELETE, new Delete(Bytes.toBytes("fakeRow")));

  RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
      false,
      Arrays.asList(
          new Action(0, mutation, null),
          new Action(1, mutation, null),
          new Action(2, mutation, null))
  ));
  assertThat(actions.getException(), IsNull.nullValue());
  assertThat(actions.getResultOrExceptionList().size(), is(3));
}
项目:c5    文件:HRegionBridgeTest.java   
@Test
public void shouldBeAbleToProcessMultiRowNonAtomicPut() throws Exception {
  ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
  RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
      regionLocation);

  MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow")));
  MutationProto mutation2 = ProtobufUtil.toMutation(MutationProto.MutationType.PUT, new Put(Bytes.toBytes("fakeRow2")));

  context.checking(new Expectations() {
    {
      exactly(3).of(hRegionInterface).put(with(any(Put.class)));

    }
  });

  RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
      false,
      Arrays.asList(
          new Action(0, mutation, null),
          new Action(1, mutation, null),
          new Action(2, mutation2, null))
  ));
  assertThat(actions.getException(), IsNull.nullValue());
  assertThat(actions.getResultOrExceptionList().size(), is(3));
}
项目:c5    文件:HRegionBridgeTest.java   
@Test
public void shouldFailWhenWeTryToMutateAndGet() throws Exception {
  ByteBuffer regionLocation = ByteBuffer.wrap(Bytes.toBytes("testTable"));
  RegionSpecifier regionSpecifier = new RegionSpecifier(RegionSpecifier.RegionSpecifierType.REGION_NAME,
      regionLocation);

  MutationProto mutation = ProtobufUtil.toMutation(MutationProto.MutationType.DELETE, new Delete(Bytes.toBytes("fakeRow")));
  Get get = ProtobufUtil.toGet(new org.apache.hadoop.hbase.client.Get(Bytes.toBytes("fakeRow2")), false);
  Get exists = ProtobufUtil.toGet(new org.apache.hadoop.hbase.client.Get(Bytes.toBytes("fakeRow2")), true);

  RegionActionResult actions = hRegionBridge.processRegionAction(new RegionAction(regionSpecifier,
      true,
      Arrays.asList(
          new Action(0, mutation, get),
          new Action(1, mutation, exists))
  ));
  assertThat(actions.getException(), IsNull.notNullValue());
  assertThat(actions.getResultOrExceptionList().size(), is(0));
}
项目:ews-java-api    文件:TaskTest.java   
/**
 * Test for checking if the value changes in case of a thrown exception
 *
 * @throws Exception
 */
@Test
public void testDontChangeValueOnException() throws Exception {
  // set valid value
  final Double targetValue = 50.5;
  taskMock.setPercentComplete(targetValue);

  assertThat(taskMock.getPercentComplete(), IsNot.not(IsNull.nullValue()));
  assertThat(taskMock.getPercentComplete(), IsInstanceOf.instanceOf(Double.class));
  assertThat(taskMock.getPercentComplete(), IsEqual.equalTo(targetValue));

  final Double invalidValue = -0.1;
  try {
    taskMock.setPercentComplete(invalidValue);
  } catch (IllegalArgumentException ex) {
    // ignored
  }

  assertThat(taskMock.getPercentComplete(), IsNot.not(IsNull.nullValue()));
  assertThat(taskMock.getPercentComplete(), IsInstanceOf.instanceOf(Double.class));
  assertThat(taskMock.getPercentComplete(), IsEqual.equalTo(targetValue));
}
项目:your-all-in-one    文件:BaseNodeRestControllerTest.java   
/** 
 * service-function to test the response for creating a node as child of the parentId
 * @param parentId               parentId of the new task
 * @param node                   the node to create
 * @return                       the sysUID of the new node
 * @throws Exception             io-Exceptions possible
 */
public String testCreateNode(final String parentId, final BaseNode node) throws Exception {
    // request
    MockHttpServletRequestBuilder req = 
                    MockMvcRequestBuilders.post("/nodes/create/" 
                    + node.getClassName() 
                    + "/" + parentId);

    // set params
    req.content(convertObjectToJsonBytes(node));

    // set contenttype;
    req.contentType(APPLICATION_JSON_UTF8);
    ResultActions res = testBaseRequest(req);

    // check data
    res.andExpect(jsonPath("$.node.name", is(node.getName())))
       .andExpect(jsonPath("$.node.sysUID", IsNull.notNullValue()));

    // create JSON from String
    String response = res.andReturn().getResponse().getContentAsString();
    String sysUID = JsonPath.read(response, "$.node.sysUID");

    return sysUID;
}
项目:spring-data-solr    文件:SolrTemplateTests.java   
/**
 * @throws IOException
 * @throws SolrServerException
 * @see DATASOLR-72
 */
@Test
public void schemaShouldBeUpdatedPriorToSavingEntity() throws SolrServerException, IOException {

    NamedList<Object> nl = new NamedList<Object>();
    nl.add("json", "{ \"schema\" : {\"name\" : \"core1\" }, \"version\" : 1.5 }");
    Mockito.when(solrServerMock.request(Mockito.any(SolrSchemaRequest.class))).thenReturn(nl);
    Mockito.when(solrServerMock.request(Mockito.any(SolrSchemaRequest.class))).thenReturn(nl);

    solrTemplate = new SolrTemplate(solrServerMock, "core1");
    solrTemplate.setSchemaCreationFeatures(Collections.singletonList(Feature.CREATE_MISSING_FIELDS));
    solrTemplate.afterPropertiesSet();
    solrTemplate.saveBean(new DocumentWithIndexAnnotations());

    ArgumentCaptor<SolrRequest> requestCaptor = ArgumentCaptor.forClass(SolrRequest.class);
    Mockito.verify(solrServerMock, Mockito.times(3)).request(requestCaptor.capture());

    SolrRequest capturedRequest = requestCaptor.getValue();

    Assert.assertThat(capturedRequest.getMethod(), IsEqual.equalTo(SolrRequest.METHOD.POST));
    Assert.assertThat(capturedRequest.getPath(), IsEqual.equalTo("/schema/fields"));
    Assert.assertThat(capturedRequest.getContentStreams(), IsNull.notNullValue());
}
项目:spring-data-solr    文件:ITestSolrTemplate.java   
@Test
public void testFunctionQueryInFieldProjection() {
    ExampleSolrBean bean1 = new ExampleSolrBean("id-1", "one", null);
    bean1.setStore("45.17614,-93.87341");
    ExampleSolrBean bean2 = new ExampleSolrBean("id-2", "one two", null);
    bean2.setStore("40.7143,-74.006");

    solrTemplate.saveBeans(Arrays.asList(bean1, bean2));
    solrTemplate.commit();

    Query q = new SimpleQuery("*:*");
    q.addProjectionOnField(new DistanceField("distance", "store", new Point(45.15, -93.85)));
    Page<ExampleSolrBean> result = solrTemplate.queryForPage(q, ExampleSolrBean.class);
    for (ExampleSolrBean bean : result) {
        Assert.assertThat(bean.getDistance(), IsNull.notNullValue());
    }

}
项目:spring-data-solr    文件:ITestSolrTemplate.java   
/**
 * @see DATASOLR-142
 */
@Test
public void testDistaneFunctionWithGeoLocationQueryInFieldProjection() {
    ExampleSolrBean bean1 = new ExampleSolrBean("id-1", "one", null);
    bean1.setStore("45.17614,-93.87341");
    ExampleSolrBean bean2 = new ExampleSolrBean("id-2", "one two", null);
    bean2.setStore("40.7143,-74.006");

    solrTemplate.saveBeans(Arrays.asList(bean1, bean2));
    solrTemplate.commit();

    Query q = new SimpleQuery("*:*");
    q.addProjectionOnField(new DistanceField("distance", "store", new GeoLocation(45.15, -93.85)));
    Page<ExampleSolrBean> result = solrTemplate.queryForPage(q, ExampleSolrBean.class);
    for (ExampleSolrBean bean : result) {
        Assert.assertThat(bean.getDistance(), IsNull.notNullValue());
    }

}
项目:easyrec    文件:ClusterServiceTest.java   
@Test
public void testRenameCluster() {
     Tree<ClusterVO, ItemAssocVO<Integer,Integer>> clusters = clusterService.getClustersForTenant(1);
     ClusterVO root = clusters.getRoot();
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
    assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.nullValue());
     try {
        clusterService.renameCluster(1, "CLUSTER1", "CLUSTER3");
     } catch (ClusterException ce) {
         logger.info(ce);
     }
     printCluster(clusters, root);
     assertThat(clusters.getHeight(), is(2));
     assertThat(clusters.getChildCount(root), is(2));
     assertThat(clusters.getVertexCount(), is(5));
     assertThat(clusterService.loadCluster(1,"CLUSTER3"), IsNull.notNullValue());
}
项目:gocd    文件:PackageXmlViewModelTest.java   
@Test
public void shouldPopulateModificationDetailsForPackageMaterial() {
    String userName = "user";
    String comment = "comments";
    Date checkinDate = new Date(System.currentTimeMillis());
    String revision = "package-1.0.0.rpm";
    Element modificationsTag = DocumentHelper.createDocument().addElement("modifications");
    Modifications modifications = new Modifications(new Modification(userName, comment, null, checkinDate, revision));

    XmlWriterContext writerContext = mock(XmlWriterContext.class);
    when(writerContext.getBaseUrl()).thenReturn("http://someurl:8153/go");
    new PipelineXmlViewModel.PackageXmlViewModel(MaterialsMother.packageMaterial()).populateXmlForModifications(modifications, writerContext, modificationsTag);
    Element changeSet = modificationsTag.element("changeset");
    assertThat(changeSet, is(not(IsNull.nullValue())));
    assertThat(changeSet.attributeValue("changesetUri"), is("http://someurl:8153/go/api/materials/1/changeset/package-1.0.0.rpm.xml"));
    assertThat(changeSet.element("user").getText(), is(userName));
    assertThat(changeSet.element("revision").getText(), is(revision));
    assertThat(changeSet.element("checkinTime").getText(), is(DateUtils.formatISO8601(checkinDate)));
    assertThat(changeSet.element("message").getText(), is(comment));
}
项目:gocd    文件:InstanceFactoryTest.java   
@Test
public void shouldCreateASingleJobIfRunOnAllAgentsIsFalse() throws Exception {
    JobConfig jobConfig = new JobConfig("foo");

    SchedulingContext context = mock(SchedulingContext.class);
    when(context.getEnvironmentVariablesConfig()).thenReturn(new EnvironmentVariablesConfig());
    when(context.overrideEnvironmentVariables(any(EnvironmentVariablesConfig.class))).thenReturn(context);

    RunOnAllAgents.CounterBasedJobNameGenerator jobNameGenerator = new RunOnAllAgents.CounterBasedJobNameGenerator(CaseInsensitiveString.str(jobConfig.name()));
    JobInstances jobs = instanceFactory.createJobInstance(new CaseInsensitiveString("someStage"), jobConfig, new DefaultSchedulingContext(), new TimeProvider(), jobNameGenerator);

    assertThat(jobs.toArray(), hasItemInArray(hasProperty("name", is("foo"))));
    assertThat(jobs.toArray(), hasItemInArray(hasProperty("agentUuid", IsNull.nullValue())));
    assertThat(jobs.toArray(), hasItemInArray(hasProperty("runOnAllAgents", is(false))));
    assertThat(jobs.size(), is(1));
}
项目:elasticsearch_my    文件:AnalyzeActionIT.java   
public void testDetailAnalyze() throws Exception {
    assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
        .setSettings(
                Settings.builder()
                .put("index.analysis.char_filter.my_mapping.type", "mapping")
                .putArray("index.analysis.char_filter.my_mapping.mappings", "PH=>F")
                .put("index.analysis.analyzer.test_analyzer.type", "custom")
                .put("index.analysis.analyzer.test_analyzer.position_increment_gap", "100")
                .put("index.analysis.analyzer.test_analyzer.tokenizer", "standard")
                .putArray("index.analysis.analyzer.test_analyzer.char_filter", "my_mapping")
                .putArray("index.analysis.analyzer.test_analyzer.filter", "snowball")));
    ensureGreen();

    for (int i = 0; i < 10; i++) {
        AnalyzeResponse analyzeResponse = admin().indices().prepareAnalyze().setIndex(indexOrAlias()).setText("THIS IS A PHISH")
            .setExplain(true).addCharFilter("my_mapping").setTokenizer("keyword").addTokenFilter("lowercase").get();

        assertThat(analyzeResponse.detail().analyzer(), IsNull.nullValue());
        //charfilters
        assertThat(analyzeResponse.detail().charfilters().length, equalTo(1));
        assertThat(analyzeResponse.detail().charfilters()[0].getName(), equalTo("my_mapping"));
        assertThat(analyzeResponse.detail().charfilters()[0].getTexts().length, equalTo(1));
        assertThat(analyzeResponse.detail().charfilters()[0].getTexts()[0], equalTo("THIS IS A FISH"));
        //tokenizer
        assertThat(analyzeResponse.detail().tokenizer().getName(), equalTo("keyword"));
        assertThat(analyzeResponse.detail().tokenizer().getTokens().length, equalTo(1));
        assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getTerm(), equalTo("THIS IS A FISH"));
        assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getStartOffset(), equalTo(0));
        assertThat(analyzeResponse.detail().tokenizer().getTokens()[0].getEndOffset(), equalTo(15));
        //tokenfilters
        assertThat(analyzeResponse.detail().tokenfilters().length, equalTo(1));
        assertThat(analyzeResponse.detail().tokenfilters()[0].getName(), equalTo("lowercase"));
        assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens().length, equalTo(1));
        assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens()[0].getTerm(), equalTo("this is a fish"));
        assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens()[0].getPosition(), equalTo(0));
        assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens()[0].getStartOffset(), equalTo(0));
        assertThat(analyzeResponse.detail().tokenfilters()[0].getTokens()[0].getEndOffset(), equalTo(15));
    }
}
项目:elasticsearch_my    文件:AnalyzeActionIT.java   
public void testDetailAnalyzeWithNoIndex() throws Exception {
    //analyzer only
    AnalyzeResponse analyzeResponse = client().admin().indices().prepareAnalyze("THIS IS A TEST")
        .setExplain(true).setAnalyzer("simple").get();

    assertThat(analyzeResponse.detail().tokenizer(), IsNull.nullValue());
    assertThat(analyzeResponse.detail().tokenfilters(), IsNull.nullValue());
    assertThat(analyzeResponse.detail().charfilters(), IsNull.nullValue());
    assertThat(analyzeResponse.detail().analyzer().getName(), equalTo("simple"));
    assertThat(analyzeResponse.detail().analyzer().getTokens().length, equalTo(4));
}
项目:android_pager_adapters    文件:PagerAdaptersLoggingTest.java   
@Test
public void testSetLogger() {
    PagerAdaptersLogging.setLogger(null);
    assertThat(PagerAdaptersLogging.getLogger(), is(IsNot.not(IsNull.nullValue())));
    final Logger logger = new SimpleLogger(Log.DEBUG);
    PagerAdaptersLogging.setLogger(logger);
    assertThat(PagerAdaptersLogging.getLogger(), is(logger));
}
项目:android_fragments    文件:FragmentsLoggingTest.java   
@Test
public void testSetLogger() {
    FragmentsLogging.setLogger(null);
    assertThat(FragmentsLogging.getLogger(), is(IsNot.not(IsNull.nullValue())));
    final Logger logger = new SimpleLogger(Log.DEBUG);
    FragmentsLogging.setLogger(logger);
    assertThat(FragmentsLogging.getLogger(), is(logger));
}
项目:jaskell    文件:Skip1Test.java   
/**
 * Method: parse(State<E> s)
 */
@Test
public void simple() throws Exception {
    State<Character, Integer, Integer> state = newState("left right left right");
    Parsec<String, Character> parser = skip1(text("left"));
    String re = parser.parse(state);
    Assert.assertThat("Expect string \"left\".", re, IsNull.nullValue());
}
项目:javaaz    文件:SimpleQueueTest.java   
/**
 * Тестовый метод.
 */
@Test
public void whenPollElementShouldReturnAndDeleteIt() {

    SimpleQueue<Integer> queue = new SimpleQueue<>();
    queue.push(1);
    queue.push(2);
    queue.push(3);
    assertThat((Integer) queue.poll(), is(1));
    assertThat((Integer) queue.poll(), is(2));
    assertThat((Integer) queue.poll(), is(3));
    assertThat((Integer) queue.poll(), is(IsNull.nullValue()));

}
项目:maven-confluence-plugin    文件:SiteTest.java   
/**
 * Must be ignored because i got
 * 
 * java.lang.NoClassDefFoundError: org/bsc/maven/reporting/model/Site
 * at org.bsc.maven.reporting.test.SiteTest.jaxbTest(SiteTest.java:30)
 * 
 * @throws Exception 
 */
@Test @Ignore
public void jaxbTest() throws Exception {

    java.io.File basepath = new java.io.File("src/site/confluence/home.confluence");
    java.net.URI relativeURI = new java.net.URI("template.confluence");
    System.out.printf("uri=[%s]\n", basepath.toURI().resolve(relativeURI) );

    JAXBContext jc = JAXBContext.newInstance(Site.class);

    Unmarshaller unmarshaller = jc.createUnmarshaller();

    Object result = unmarshaller.unmarshal( getClass().getClassLoader().getResourceAsStream("site.xml"));

    Assert.assertThat(result, IsNull.notNullValue());
    Assert.assertThat(result, IsInstanceOf.instanceOf(Site.class));

    Site site = (Site) result;

    site.setBasedir( basepath );
    Assert.assertThat(site.getHome().getUri(), IsNull.notNullValue());        
    Assert.assertThat(site.getHome().getName(), IsEqual.equalTo("home"));        
    Assert.assertThat(site.getHome().getSource().getName(), IsEqual.equalTo("home.confluence"));        
    Assert.assertThat(site.getHome(), IsNull.notNullValue());        
    Assert.assertThat(site.getHome().getAttachments(), IsNull.notNullValue());        
    Assert.assertThat(site.getHome().getAttachments().isEmpty(), Is.is(false));
    Assert.assertThat(site.getHome().getChildren(), IsNull.notNullValue());        
    Assert.assertThat(site.getHome().getChildren().isEmpty(), Is.is(false));
    Assert.assertThat(site.getLabels().isEmpty(), Is.is(false));

    for( String label : site.getLabels() ) {
        System.out.printf( "label=[%s]\n", label);
    }
}
项目:maven-confluence-plugin    文件:SiteTest.java   
@Test
public void shouldSupportReferenceNode() throws IOException {
    final InputStream stream = getClass().getClassLoader().getResourceAsStream("withRefLink.md");
    assertThat( stream, IsNull.notNullValue());
    final InputStream inputStream = Site.processMarkdown(stream, "Test");
    assertThat( inputStream, IsNull.notNullValue());
    final String converted = IOUtils.toString(inputStream);

    assertThat(converted, containsString("[rel|Test - relativeagain]"));
    assertThat(converted, containsString("[more complex google|http://google.com|Other google]"));
    assertThat(converted, containsString("[google|http://google.com]"));
}
项目:maven-confluence-plugin    文件:AbstractRestConfluence.java   
@Test
public void getOrCreatePageAndStoreStorage() throws Exception  {

    final String spaceKey = "TEST";
    final String parentPageTitle = "Home";
    final String title = "MyPage3";


    final Model.Page p = service.getOrCreatePage(spaceKey, parentPageTitle, title);

    int version = p.getVersion();
    Assert.assertThat( p, IsNull.notNullValue());
    Assert.assertThat( p.getSpace(), IsEqual.equalTo("TEST"));
    Assert.assertThat( version > 0, Is.is(true));

    final String content = new StringBuilder()
                                    .append("<h1>")
                                    .append("TEST ")
                                    .append(System.currentTimeMillis())
                                    .append("</h1>")
                                    .append("<hr/>")
                                    .append("<b>'storage' \"storage\"</b>")
                                    .toString();
    final Model.Page p1 = service.storePage(p, new Storage(content, Storage.Representation.STORAGE));

    Assert.assertThat( p1, IsNull.notNullValue());
    Assert.assertThat( p1.getSpace(), IsEqual.equalTo("TEST"));
    Assert.assertThat( p1.getVersion(), IsEqual.equalTo(version+1));

}
项目:maven-confluence-plugin    文件:Issue106IntegrationTest.java   
@Test
public void getStorageFormat() throws IOException {

    final String credential = Credentials.basic("admin", "admin");

    final HttpUrl url =   new HttpUrl.Builder()
                                .scheme(SCHEME)
                                .host(HOST)
                                .port(PORT)
                                .addPathSegments("plugins/viewstorage/viewpagestorage.action")
                                .addQueryParameter("pageId", "1867778")
                                .build();
    final Request req = new Request.Builder()
            .header("Authorization", credential)
            .url( url )  
            .get()
            .build();

    final Response res = client.build().newCall(req).execute();

    Assert.assertThat( res, IsNull.notNullValue());
    Assert.assertThat( res.isSuccessful(), Is.is(true));
    final ResponseBody body = res.body();
    Assert.assertThat( body, IsNull.notNullValue());

    System.out.printf( "BODY\n%s\n", body.string() );

}
项目:maven-confluence-plugin    文件:Issue106IntegrationTest.java   
private Response deletePage( String id ) {

    try {
        final String credential = Credentials.basic("admin", "admin");

        final HttpUrl.Builder url = new HttpUrl.Builder()
                .scheme(SCHEME)
                .host(HOST)
                .port(PORT)
                .addPathSegments("rest/api/content")
                ;
        final Request req1 = new Request.Builder()
                .header("Authorization", credential)
                .url( url.addPathSegment(id).build() )
                .delete()
                .build();

        final Response res1 = client.build().newCall(req1).execute();
        Assert.assertThat( res1, IsNull.notNullValue());
        Assert.assertThat( res1.code(), IsEqual.equalTo(204));

        return res1;

    } catch (IOException ex) {
        Assert.fail( ex.getMessage() );
    }

    return null;
}
项目:testrecorder    文件:ContainsMatcher.java   
private Matcher<T> bestMatcher() {
    for (Matcher<T> matcher : elements) {
        if (matcher.getClass() != IsNull.class) {
            return matcher;
        }
    }
    return equalTo(null);
}