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


Java Lists类代码示例

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


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

示例1: shouldInheritClusterOverride

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void shouldInheritClusterOverride() {
  BoundCluster cluster =
      new BoundCluster(
          ClusterSpec.builder().withPeerInfo("protocol_versions", Lists.newArrayList(5)).build(),
          0L,
          null);
  BoundDataCenter dc = new BoundDataCenter(cluster);
  BoundNode node =
      new BoundNode(
          new LocalAddress(UUID.randomUUID().toString()),
          NodeSpec.builder().withName("node0").withId(0L).build(),
          Collections.emptyMap(),
          cluster,
          dc,
          null,
          timer,
          null, // channel reference only needed for closing, not useful in context of this test.
          false);

  assertThat(node.getFrameCodec().getSupportedProtocolVersions()).containsOnly(5);
  assertThat(dc.getFrameCodec().getSupportedProtocolVersions()).containsOnly(5);
  assertThat(cluster.getFrameCodec().getSupportedProtocolVersions()).containsOnly(5);
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:25,代码来源:ProtocolVersionSupportTest.java

示例2: testShouldUseProtocolVersionOverride

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void testShouldUseProtocolVersionOverride() {
  BoundCluster cluster = new BoundCluster(ClusterSpec.builder().build(), 0L, null);
  BoundDataCenter dc = new BoundDataCenter(cluster);
  BoundNode node =
      new BoundNode(
          new LocalAddress(UUID.randomUUID().toString()),
          NodeSpec.builder()
              .withName("node0")
              .withId(0L)
              .withCassandraVersion("2.1.17")
              .withPeerInfo("protocol_versions", Lists.newArrayList(4))
              .build(),
          Collections.emptyMap(),
          cluster,
          dc,
          null,
          timer,
          null, // channel reference only needed for closing, not useful in context of this test.
          false);

  assertThat(node.getFrameCodec().getSupportedProtocolVersions()).containsOnly(4);
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:24,代码来源:ProtocolVersionSupportTest.java

示例3: testTypeExamples

import org.assertj.core.util.Lists; //导入依赖的package包/类
@DataProvider
public static Object[][] testTypeExamples() {
    final List<TypeDeclaration> uriParameters = Lists.newArrayList();
    uriParameters.add(new UriParameter("projectKey"));
    uriParameters.add(new UriParameter("key"));
    uriParameters.add(new UriParameter("ID", "^" + UUID_PATTERN + "$"));
    return new Object[][] {
            {"https://api.sphere.io/{projectKey}", "https://api.sphere.io/::" + DIRECTORY_PATTERN, uriParameters},
            {"https://api.sphere.io/{projectKey}/", "https://api.sphere.io/::" + DIRECTORY_PATTERN, uriParameters},
            {"https://api.sphere.io/{projectKey}/test", "https://api.sphere.io/::" + DIRECTORY_PATTERN + "/test", uriParameters},
            {"{projectKey}", "::" + DIRECTORY_PATTERN, uriParameters},
            {"{projectKey}/", "::" + DIRECTORY_PATTERN, uriParameters},
            {"{projectKey}/test", "::" + DIRECTORY_PATTERN + "/test", uriParameters},
            {"{projectKey}/{ID}/", "::" + DIRECTORY_PATTERN + "/::" + UUID_PATTERN, uriParameters},
            {"/{projectKey}", "::" + DIRECTORY_PATTERN, uriParameters},
            {"/{projectKey}/", "::" + DIRECTORY_PATTERN, uriParameters},
            {"/{projectKey}/test", "::" + DIRECTORY_PATTERN + "/test", uriParameters},
            {"/{projectKey}/{ID}/", "::" + DIRECTORY_PATTERN + "/::" + UUID_PATTERN, uriParameters},
            {"/{projectKey}/categories/key={key}/", "::" + DIRECTORY_PATTERN + "/categories/::key=" + DIRECTORY_PATTERN, uriParameters},
    };
}
 
开发者ID:vrapio,项目名称:vrap,代码行数:22,代码来源:RatpackPathMapperTest.java

示例4: saveTask

import org.assertj.core.util.Lists; //导入依赖的package包/类
@POST
@Path("/task")
public RestfulReturnResult saveTask(@Session HttpSession session, com.cloudwise.sap.niping.common.vo.Task taskVO) {
    Optional<Task> taskOptional = taskConverter.convertTaskVO(Optional.ofNullable(taskVO));
    if (taskOptional.isPresent()) {
        Task task = taskOptional.get();
        task.setAccountId(NiPingAuthFilter.getAccountId(session));
        try {
            log.info("user {} save task {}", task);
            String taskId = taskService.saveTask(task);

            String selectMonitorIdString = taskVO.getSelectMonitorIdString();
            ArrayList<String> monitorIds = Lists.newArrayList();
            if (StringUtils.isNotBlank(selectMonitorIdString)) {
                monitorIds = new ArrayList<String>(Arrays.asList(selectMonitorIdString.split(",")));
            }
            taskService.assignTask(monitorIds, taskId);
            taskService.modifyTaskRedispatcher(taskId);
        } catch (NiPingException e) {
            return new RestfulReturnResult(e, null);
        }
    }
    return new RestfulReturnResult(SUCCESS, null);
}
 
开发者ID:CloudWise-OpenSource,项目名称:SAPNetworkMonitor,代码行数:25,代码来源:TaskResource.java

示例5: testBatchOperations

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void testBatchOperations() {

    final Contact contact1 = new Contact("newid1", "newtitle");
    final Contact contact2 = new Contact("newid2", "newtitle");
    final ArrayList<Contact> contacts = new ArrayList<Contact>();
    contacts.add(contact1);
    contacts.add(contact2);
    repository.save(contacts);

    final ArrayList<String> ids = new ArrayList<String>();
    ids.add(contact1.getLogicId());
    ids.add(contact2.getLogicId());
    final List<Contact> result = Lists.newArrayList(repository.findAll(ids));

    assertThat(result.size()).isEqualTo(2);

    repository.delete(contacts);

    final List<Contact> result2 = Lists.newArrayList(repository.findAll(ids));
    assertThat(result2.size()).isEqualTo(0);
}
 
开发者ID:Microsoft,项目名称:spring-data-documentdb,代码行数:23,代码来源:ContactRepositoryIT.java

示例6: shouldNotifyListenerOnHandleTrackerResponse

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void shouldNotifyListenerOnHandleTrackerResponse() throws URISyntaxException, AnnounceException {
    final TorrentWithStats torrent = Mockito.mock(TorrentWithStats.class);
    final ConnectionHandler connectionHandler = Mockito.mock(ConnectionHandler.class);
    final URI uri = new URI("http://example.tracker.com/announce");

    final DefaultTrackerClient trackerClient = new DefaultTrackerClient(torrent, connectionHandler, uri);
    final DefaultResponseListener listener = Mockito.spy(new DefaultResponseListener(new CountDownLatch(1), new CountDownLatch(1)));
    trackerClient.register(listener);

    final HTTPAnnounceResponseMessage message = Mockito.mock(HTTPAnnounceResponseMessage.class);
    Mockito.when(message.getComplete()).thenReturn(1560);
    Mockito.when(message.getIncomplete()).thenReturn(54676865);
    Mockito.when(message.getInterval()).thenReturn(1800);
    Mockito.when(message.getPeers()).thenReturn(Lists.emptyList());

    trackerClient.handleTrackerAnnounceResponse(message);

    assertThat(listener.getAnnounceResponseCountDown().getCount()).isEqualTo(0);
    assertThat(listener.getDiscoverPeerCountDown().getCount()).isEqualTo(0);
    Mockito.verify(listener, Mockito.times(1)).handleAnnounceResponse(torrent);
    Mockito.verify(listener, Mockito.times(1)).handleDiscoveredPeers(
            Matchers.eq(torrent),
            Matchers.anyListOf(Peer.class)
    );
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:27,代码来源:TrackerClientTest.java

示例7: shouldAnnounce

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void shouldAnnounce() throws URISyntaxException, AnnounceException {
    final TorrentWithStats torrent = Mockito.mock(TorrentWithStats.class);
    final ConnectionHandler connectionHandler = Mockito.mock(ConnectionHandler.class);
    final URI uri = new URI("http://example.tracker.com/announce");

    final HTTPAnnounceResponseMessage message = Mockito.mock(HTTPAnnounceResponseMessage.class);
    Mockito.when(message.getComplete()).thenReturn(1560);
    Mockito.when(message.getIncomplete()).thenReturn(54676865);
    Mockito.when(message.getInterval()).thenReturn(1800);
    Mockito.when(message.getPeers()).thenReturn(Lists.emptyList());

    final DefaultTrackerClient trackerClient = Mockito.spy(new DefaultTrackerClient(torrent, connectionHandler, uri));
    Mockito.when(trackerClient.makeCallAndGetResponseAsByteBuffer(Mockito.any(RequestEvent.class))).thenReturn(message);

    final DefaultResponseListener listener = Mockito.spy(new DefaultResponseListener(new CountDownLatch(1), new CountDownLatch(1)));
    trackerClient.register(listener);

    trackerClient.announce(RequestEvent.NONE);
    Mockito.verify(listener, Mockito.times(1)).handleAnnounceResponse(torrent);
    Mockito.verify(listener, Mockito.times(1)).handleDiscoveredPeers(
            Matchers.eq(torrent),
            Matchers.anyListOf(Peer.class)
    );
}
 
开发者ID:anthonyraymond,项目名称:joal,代码行数:26,代码来源:TrackerClientTest.java

示例8: testAmb

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void testAmb() throws Exception {
    Flowable<String> integerFlowable1 = Flowable.interval(5, TimeUnit.MILLISECONDS)
                                                .take(50)
                                                .map(x -> "F1:" + x)
                                                .delay(2, TimeUnit.SECONDS)
                                                .subscribeOn(Schedulers.computation());
    Flowable<String> integerFlowable2 = Flowable.interval(500, TimeUnit.MILLISECONDS)
                                                .take(50)
                                                .map(x -> "F2:" + x)
                                                .delay(1, TimeUnit.SECONDS)
                                                .subscribeOn(Schedulers.computation());
    Flowable<String> integerFlowable3 = Flowable
            .interval(1, TimeUnit.SECONDS)
            .take(50).map(x -> "F3:" + x)
            .delay(3, TimeUnit.SECONDS)
            .subscribeOn(Schedulers.computation());

    Flowable.amb(Lists.newArrayList(integerFlowable1, integerFlowable2, integerFlowable3)).subscribe(System.out::println);

    Thread.sleep(50000);
}
 
开发者ID:dhinojosa,项目名称:rxjavatraining,代码行数:23,代码来源:BasicObservableTest.java

示例9: orderStringWithLambda

import org.assertj.core.util.Lists; //导入依赖的package包/类
/**
 * lambda 表达式示例
 * 
 * (String o1, String o2) -> {
 *		return Integer.compare(o1.length(), o2.length());
 * }
 * 
 * (o1, o2) -> {
 *		return Integer.compare(o1.length(), o2.length());
 * }
 * 
 * 因为代码块里面的代码只有简单的一句,因此代码块的 {} 也可以省略,而且连 return 语句也可以省略
 * (o1, o2) -> Integer.compare(o1.length(), o2.length())
 * 
 * 你可以像对待方法参数一样向 lambda 表达式的参数添加注解或者 final 修饰符
 * (final String o1, @NotNull String o2) 
 * 
 */
@Test
public void orderStringWithLambda() {
	List<String> strs = Lists.newArrayList("hello", "java", "and", "lambda");
	
	Collections.sort(strs, (String o1, String o2) -> {
		return Integer.compare(o1.length(), o2.length());
	});
	
	// 因为这里两个参数的类型可以自动推导所以这里参数的类型也可以省略
	Collections.sort(strs, (o1, o2) -> {
		return Integer.compare(o1.length(), o2.length());
	});
	
	// return 语句也不是必须的,不需要 return 是 {} 也可以省略
	Collections.sort(strs, (o1, o2) -> Integer.compare(o1.length(), o2.length()));
	
	// 使用 Comparator#comparing 来生成 Comparator
	// 这个时候只有一个参数,参数的括号也可以省略
	Collections.sort(strs, comparing(str -> str.length()));
	
	// 使用方法引用时,参数也不需要了
	Collections.sort(strs, comparing(String::length));
	
	strs.forEach(System.out::println);
}
 
开发者ID:walle-liao,项目名称:jaf-examples,代码行数:44,代码来源:LambdaTests1.java

示例10: parallelismTest

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void parallelismTest() {
	// 并行流默认采用的 ForkJoinPool 实现
	ForkJoinPool commonPool = ForkJoinPool.commonPool();
	
	System.out.println(commonPool.getParallelism());    // 7
	
	// 默认的并行级别等于机器可用的cpu数量
	// 可以用下面的方式修改默认的并行级别
	// -Djava.util.concurrent.ForkJoinPool.common.parallelism=3
	Lists.newArrayList("a1", "a2", "b1", "c2", "c1", "d1", "f1", "c3", "h1")
	    .parallelStream()
	    .filter(s -> {
	        System.out.format("filter: %s [%s]\n", s, Thread.currentThread().getName());
	        return true;
	    })
	    .map(s -> {
	        System.out.format("map: %s [%s]\n", s, Thread.currentThread().getName());
	        return s.toUpperCase();
	    })
	    .forEach(s -> System.out.format("forEach: %s [%s]\n", s, Thread.currentThread().getName()));
}
 
开发者ID:walle-liao,项目名称:jaf-examples,代码行数:23,代码来源:ParallelStreamTests.java

示例11: parallelStreamStortTest

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void parallelStreamStortTest() {
	// filter,map 方法可以并行执行,但是 sort 方法却只在一个线程中串行执行

	// 并行流的 sort 采用的是 java8 里面的 Arrays.parallelSort() 方法实现
	// If the length of the specified array is less than the minimum
    // granularity, then it is sorted using the appropriate Arrays.sort() method.
	// 默认的阈值 1 << 13 (8192),即当排序元素的个数小于 8192 个时,默认采用的是串行排序
	Lists.newArrayList("a1", "a2", "b1", "c2", "c1")
	    .parallelStream()
	    .filter(s -> {
	        System.out.format("filter: %s [%s]\n", s, Thread.currentThread().getName());
	        return true;
	    })
	    .map(s -> {
	        System.out.format("map: %s [%s]\n", s, Thread.currentThread().getName());
	        return s.toUpperCase();
	    })
	    .sorted((s1, s2) -> {
	        System.out.format("sort: %s <> %s [%s]\n", s1, s2, Thread.currentThread().getName());
	        return s1.compareTo(s2);
	    })
	    .forEach(s -> System.out.format("forEach: %s [%s]\n", s, Thread.currentThread().getName()));
}
 
开发者ID:walle-liao,项目名称:jaf-examples,代码行数:25,代码来源:ParallelStreamTests.java

示例12: test_that_cleanUpInactiveAndOrphanedKmsKeys_succeeds

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void test_that_cleanUpInactiveAndOrphanedKmsKeys_succeeds() {

    int inactivePeriod = 30;
    String keyRecordId = "key record id";
    String awsKeyId = "aws key id";
    String keyRegion = "key region";
    AwsIamRoleKmsKeyRecord keyRecord = mock(AwsIamRoleKmsKeyRecord.class);
    when(keyRecord.getId()).thenReturn(keyRecordId);
    when(keyRecord.getAwsKmsKeyId()).thenReturn(awsKeyId);
    when(keyRecord.getAwsRegion()).thenReturn(keyRegion);
    when(dateTimeSupplier.get()).thenReturn(now);

    OffsetDateTime inactiveCutoffDate = now.minusDays(inactivePeriod);
    when(awsIamRoleDao.getInactiveOrOrphanedKmsKeys(inactiveCutoffDate)).thenReturn(Lists.newArrayList(keyRecord));

    // perform the call
    cleanUpService.cleanUpInactiveAndOrphanedKmsKeys(inactivePeriod, 0);

    verify(awsIamRoleDao).getInactiveOrOrphanedKmsKeys(inactiveCutoffDate);
    verify(kmsService).deleteKmsKeyById(keyRecordId);
    verify(kmsService).scheduleKmsKeyDeletion(awsKeyId, keyRegion, SOONEST_A_KMS_KEY_CAN_BE_DELETED);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:24,代码来源:CleanUpServiceTest.java

示例13: test_that_cleanUpInactiveAndOrphanedKmsKeys_does_not_throw_exception_on_failure

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void test_that_cleanUpInactiveAndOrphanedKmsKeys_does_not_throw_exception_on_failure() {

    int inactivePeriod = 30;
    String keyRecordId = "key record id";
    String awsKeyId = "aws key id";
    String keyRegion = "key region";
    AwsIamRoleKmsKeyRecord keyRecord = mock(AwsIamRoleKmsKeyRecord.class);
    when(keyRecord.getId()).thenReturn(keyRecordId);
    when(keyRecord.getAwsKmsKeyId()).thenReturn(awsKeyId);
    when(keyRecord.getAwsRegion()).thenReturn(keyRegion);
    when(dateTimeSupplier.get()).thenReturn(now);

    OffsetDateTime inactiveCutoffDate = now.minusDays(inactivePeriod);
    when(awsIamRoleDao.getInactiveOrOrphanedKmsKeys(inactiveCutoffDate)).thenReturn(Lists.newArrayList(keyRecord));

    when(awsIamRoleDao.deleteKmsKeyById(keyRecordId)).thenThrow(new NullPointerException());

    cleanUpService.cleanUpInactiveAndOrphanedKmsKeys(inactivePeriod);
}
 
开发者ID:Nike-Inc,项目名称:cerberus-management-service,代码行数:21,代码来源:CleanUpServiceTest.java

示例14: setup

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Before
public void setup() {
    this.mockMvc = MockMvcBuilders.standaloneSetup(vetController).build();

    Vet james = new Vet();
    james.setFirstName("James");
    james.setLastName("Carter");
    james.setId(1);
    Vet helen = new Vet();
    helen.setFirstName("Helen");
    helen.setLastName("Leary");
    helen.setId(2);
    Specialty radiology = new Specialty();
    radiology.setId(1);
    radiology.setName("radiology");
    helen.addSpecialty(radiology);
    given(this.clinicService.findVets()).willReturn(Lists.newArrayList(james, helen));
}
 
开发者ID:PacktPublishing,项目名称:DevOps-for-Web-Development,代码行数:19,代码来源:VetControllerTests.java

示例15: roundRobinsSingleInstanceInAzAndIgnoresOtherAzInstances

import org.assertj.core.util.Lists; //导入依赖的package包/类
@Test
public void roundRobinsSingleInstanceInAzAndIgnoresOtherAzInstances() {
    // given
    List<InstanceInfo> expectedInstances = generateListWithMockInstanceInfos(Lists.newArrayList("us-west-2a", "us-west-2b", "us-west-2c"));
    doReturn(expectedInstances).when(serviceSpy).getActiveInstanceInfosForVipAddressBlocking(vip);

    // when
    Optional<InstanceInfo> result1 = serviceSpy.getActiveInstanceInfoForVipAddressBlocking(vip);
    Optional<InstanceInfo> result2 = serviceSpy.getActiveInstanceInfoForVipAddressBlocking(vip);
    Optional<InstanceInfo> result3 = serviceSpy.getActiveInstanceInfoForVipAddressBlocking(vip);
    Optional<InstanceInfo> result4 = serviceSpy.getActiveInstanceInfoForVipAddressBlocking(vip);

    // then
    assertThat(result1).isNotEmpty();
    assertThat(result1.get()).isEqualTo(expectedInstances.get(0));
    assertThat(result2).isNotEmpty();
    assertThat(result2.get()).isEqualTo(expectedInstances.get(0));
    assertThat(result3).isNotEmpty();
    assertThat(result3.get()).isEqualTo(expectedInstances.get(0));
    assertThat(result4).isNotEmpty();
    assertThat(result4.get()).isEqualTo(expectedInstances.get(0));
}
 
开发者ID:Nike-Inc,项目名称:riposte,代码行数:23,代码来源:EurekaVipAddressRoundRobinWithAzAffinityServiceTest.java


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