當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。