Java Code Examples for org.assertj.core.util.Lists#emptyList()

The following examples show how to use org.assertj.core.util.Lists#emptyList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EthGetFilterChangesIntegrationTest.java    From besu with Apache License 2.0 6 votes vote down vote up
@Test
public void shouldReturnEmptyArrayIfNoAddedPendingTransactions() {
  final String filterId = filterManager.installPendingTransactionFilter();

  assertThatFilterExists(filterId);

  final JsonRpcRequestContext request = requestWithParams(String.valueOf(filterId));

  // We haven't added any transactions, so the list of pending transactions should be empty.
  final JsonRpcSuccessResponse expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
  final JsonRpcResponse actual = method.response(request);
  assertThat(actual).isEqualToComparingFieldByField(expected);

  filterManager.uninstallFilter(filterId);

  assertThatFilterDoesNotExist(filterId);
}
 
Example 2
Source File: DdiActionFeedbackTest.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
@Test
@Description("Verify the correct serialization and deserialization of the model")
public void shouldSerializeAndDeserializeObject() throws IOException {
    // Setup
    Long id = 123L;
    String time = "20190809T121314";
    DdiStatus ddiStatus = new DdiStatus(DdiStatus.ExecutionStatus.CLOSED, null, Lists.emptyList());
    DdiActionFeedback ddiActionFeedback = new DdiActionFeedback(id, time, ddiStatus);

    // Test
    String serializedDdiActionFeedback = mapper.writeValueAsString(ddiActionFeedback);
    DdiActionFeedback deserializedDdiActionFeedback = mapper.readValue(serializedDdiActionFeedback,
            DdiActionFeedback.class);

    assertThat(serializedDdiActionFeedback).contains(id.toString(), time);
    assertThat(deserializedDdiActionFeedback.getId()).isEqualTo(id);
    assertThat(deserializedDdiActionFeedback.getTime()).isEqualTo(time);
    assertThat(deserializedDdiActionFeedback.getStatus().toString()).isEqualTo(ddiStatus.toString());
}
 
Example 3
Source File: EthGetFilterChangesIntegrationTest.java    From besu with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnHashesIfNewBlocks() {
  final String filterId = filterManager.installBlockFilter();

  assertThatFilterExists(filterId);

  final JsonRpcRequestContext request = requestWithParams(String.valueOf(filterId));

  // We haven't added any blocks, so the list of new blocks should be empty.
  JsonRpcSuccessResponse expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
  JsonRpcResponse actual = method.response(request);
  assertThat(actual).isEqualToComparingFieldByField(expected);

  final Block block = appendBlock(transaction);

  // We've added one block, so there should be one new hash.
  expected = new JsonRpcSuccessResponse(null, Lists.newArrayList(block.getHash().toString()));
  actual = method.response(request);
  assertThat(actual).isEqualToComparingFieldByField(expected);

  // The queue should be flushed and return no results.
  expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
  actual = method.response(request);
  assertThat(actual).isEqualToComparingFieldByField(expected);

  filterManager.uninstallFilter(filterId);

  assertThatFilterDoesNotExist(filterId);
}
 
Example 4
Source File: EthGetFilterChangesIntegrationTest.java    From besu with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnHashesIfNewPendingTransactions() {
  final String filterId = filterManager.installPendingTransactionFilter();

  assertThatFilterExists(filterId);

  final JsonRpcRequestContext request = requestWithParams(String.valueOf(filterId));

  // We haven't added any transactions, so the list of pending transactions should be empty.
  JsonRpcSuccessResponse expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
  JsonRpcResponse actual = method.response(request);
  assertThat(actual).isEqualToComparingFieldByField(expected);

  transactions.addRemoteTransaction(transaction);

  // We've added one transaction, so there should be one new hash.
  expected =
      new JsonRpcSuccessResponse(null, Lists.newArrayList(String.valueOf(transaction.getHash())));
  actual = method.response(request);
  assertThat(actual).isEqualToComparingFieldByField(expected);

  // The queue should be flushed and return no results.
  expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
  actual = method.response(request);
  assertThat(actual).isEqualToComparingFieldByField(expected);

  filterManager.uninstallFilter(filterId);

  assertThatFilterDoesNotExist(filterId);
}
 
Example 5
Source File: PermGetNodesAllowlistTest.java    From besu with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnSuccessResponseWhenListSetAndEmpty() {
  final JsonRpcRequestContext request = buildRequest();
  final JsonRpcResponse expected =
      new JsonRpcSuccessResponse(request.getRequest().getId(), Lists.emptyList());

  when(nodeLocalConfigPermissioningController.getNodesAllowlist()).thenReturn(buildNodesList());

  final JsonRpcResponse actual = method.response(request);

  assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);

  verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist();
  verifyNoMoreInteractions(nodeLocalConfigPermissioningController);
}
 
Example 6
Source File: PermGetNodesWhitelistTest.java    From besu with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReturnSuccessResponseWhenListSetAndEmpty() {
  final JsonRpcRequestContext request = buildRequest();
  final JsonRpcResponse expected =
      new JsonRpcSuccessResponse(request.getRequest().getId(), Lists.emptyList());

  when(nodeLocalConfigPermissioningController.getNodesAllowlist()).thenReturn(buildNodesList());

  final JsonRpcResponse actual = method.response(request);

  assertThat(actual).isEqualToComparingFieldByFieldRecursively(expected);

  verify(nodeLocalConfigPermissioningController, times(1)).getNodesAllowlist();
  verifyNoMoreInteractions(nodeLocalConfigPermissioningController);
}
 
Example 7
Source File: CliqueMiningCoordinatorTest.java    From besu with Apache License 2.0 5 votes vote down vote up
private Block createEmptyBlock(
    final long blockNumber, final Hash parentHash, final KeyPair signer) {
  headerTestFixture.number(blockNumber).parentHash(parentHash);
  final BlockHeader header =
      TestHelpers.createCliqueSignedBlockHeader(headerTestFixture, signer, validators);
  return new Block(header, new BlockBody(Lists.emptyList(), Lists.emptyList()));
}
 
Example 8
Source File: OptionsProviderImplTest.java    From webauthn4j-spring-security with Apache License 2.0 5 votes vote down vote up
@Test
public void getter_setter_test() {
    WebAuthnUserDetailsService userDetailsService = mock(WebAuthnUserDetailsService.class);
    ChallengeRepository challengeRepository = mock(ChallengeRepository.class);
    OptionsProviderImpl optionsProvider = new OptionsProviderImpl(userDetailsService, challengeRepository);

    optionsProvider.setRpId("example.com");
    assertThat(optionsProvider.getRpId()).isEqualTo("example.com");
    optionsProvider.setRpName("example");
    assertThat(optionsProvider.getRpName()).isEqualTo("example");
    optionsProvider.setRpIcon("data://dummy");
    assertThat(optionsProvider.getRpIcon()).isEqualTo("data://dummy");
    List<PublicKeyCredentialParameters> publicKeyCredParams = Lists.emptyList();
    optionsProvider.setPubKeyCredParams(publicKeyCredParams);
    assertThat(optionsProvider.getPubKeyCredParams()).isEqualTo(publicKeyCredParams);
    optionsProvider.setRegistrationTimeout(10000L);
    assertThat(optionsProvider.getRegistrationTimeout()).isEqualTo(10000L);
    optionsProvider.setAuthenticationTimeout(20000L);
    assertThat(optionsProvider.getAuthenticationTimeout()).isEqualTo(20000L);
    optionsProvider.setRegistrationExtensions(new AuthenticationExtensionsClientInputs<>());
    assertThat(optionsProvider.getRegistrationExtensions()).isEqualTo(new AuthenticationExtensionsClientInputs<>());
    optionsProvider.setAuthenticationExtensions(new AuthenticationExtensionsClientInputs<>());
    assertThat(optionsProvider.getAuthenticationExtensions()).isEqualTo(new AuthenticationExtensionsClientInputs<>());

    optionsProvider.setUsernameParameter("usernameParameter");
    assertThat(optionsProvider.getUsernameParameter()).isEqualTo("usernameParameter");
    optionsProvider.setPasswordParameter("passwordParameter");
    assertThat(optionsProvider.getPasswordParameter()).isEqualTo("passwordParameter");
    optionsProvider.setCredentialIdParameter("credentialIdParameter");
    assertThat(optionsProvider.getCredentialIdParameter()).isEqualTo("credentialIdParameter");
    optionsProvider.setClientDataJSONParameter("clientDataJSONParameter");
    assertThat(optionsProvider.getClientDataJSONParameter()).isEqualTo("clientDataJSONParameter");
    optionsProvider.setAuthenticatorDataParameter("authenticatorDataParameter");
    assertThat(optionsProvider.getAuthenticatorDataParameter()).isEqualTo("authenticatorDataParameter");
    optionsProvider.setSignatureParameter("signatureParameter");
    assertThat(optionsProvider.getSignatureParameter()).isEqualTo("signatureParameter");
    optionsProvider.setClientExtensionsJSONParameter("clientExtensionsJSONParameter");
    assertThat(optionsProvider.getClientExtensionsJSONParameter()).isEqualTo("clientExtensionsJSONParameter");

}
 
Example 9
Source File: CaseAsTest.java    From JGiven with Apache License 2.0 5 votes vote down vote up
@DataProvider
public static Object[][] testData() {
    return new Object[][] {
            { "Empty value", "", Lists.<String>emptyList(), Lists.emptyList(), "" },
            { "No value", CaseAs.NO_VALUE, Arrays.asList( "a", "b" ), Arrays.asList( 1, 2 ), "a = 1, b = 2" },
            { "Placeholder with index", "$1", Arrays.asList( "a", "b" ), Arrays.asList( 1, 2 ), "1" },
            { "Placeholder without index", "$", Arrays.asList( "a", "b" ), Arrays.asList( 1, 2 ), "1" },
            { "Escaped placeholder", "$$", Arrays.asList( "a", "b" ), Arrays.asList( 1, 2 ), "$" },
            { "Multiple placeholders with switch order", "$2 + $1", Arrays.asList( "a", "b" ), Arrays.asList( 1, 2 ), "2 + 1" },
            { "Placeholders with additional text", "a = $1 and b = $2", Arrays.asList( "a", "b" ), Arrays.asList( 1, 2 ),
                    "a = 1 and b = 2" },
            { "Placeholders references by argument names in order", "int = $int and str = $str and bool = $bool",
                    Arrays.asList( "int", "str", "bool" ), Arrays.asList( 1, "some string", true ),
                    "int = 1 and str = some string and bool = true" },
            { "Placeholders references by argument names in mixed order", "str = $str and int = $int and bool = $bool",
                    Arrays.asList( "int", "str", "bool" ), Arrays.asList( 1, "some string", true ),
                    "str = some string and int = 1 and bool = true" },
            { "Placeholders references by argument names and enumeration", "str = $str and int = $1 and bool = $bool",
                    Arrays.asList( "int", "str", "bool" ), Arrays.asList( 1, "some string", true ),
                    "str = some string and int = 1 and bool = true" },
            { "Placeholders references by argument names and enumerations ", "bool = $3 and str = $2 and int = $int",
                    Arrays.asList( "int", "str", "bool" ), Arrays.asList( 1, "some string", true ),
                    "bool = true and str = some string and int = 1" },
            { "Placeholder without index mixed with names", "bool = $bool and int = $ and str = $",
                    Arrays.asList( "int", "str", "bool" ), Arrays.asList( 1, "some string", true ),
                    "bool = true and int = 1 and str = some string" },
            { "Placeholder without index mixed with names and index", "bool = $bool and str = $2 and int = $ and str = $ and bool = $3",
                    Arrays.asList( "int", "str", "bool" ), Arrays.asList( 1, "some string", true ),
                    "bool = true and str = some string and int = 1 and str = some string and bool = true" },
            { "Placeholder with unknown argument names get erased", "bool = $bool and not known = $unknown and unknown = $10",
                    Arrays.asList( "int", "str", "bool" ), Arrays.asList( 1, "some string", true ),
                    "bool = true and not known = 1 and unknown = some string" },
            { "Non-Java-Identifier char does trigger a space after a placeholder", "$]",
                    Arrays.asList( "int" ), Arrays.asList( 1 ), "1 ]" },
    };
}
 
Example 10
Source File: ProjectRepository.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Programmatic
public List<Project> findUsingAtPath(final String atPath) {
    if (atPath==null) return Lists.emptyList();
    return allUnarchivedProjects().stream()
            .filter(p->p.getAtPath().startsWith(atPath))
            .collect(Collectors.toList());
}
 
Example 11
Source File: LeaseAmendmentItem.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Programmatic
public static List<LeaseItemType> applicableToFromString(final String applicableToString){
    if (applicableToString==null || applicableToString.isEmpty()) return Lists.emptyList();
    List<LeaseItemType> result = new ArrayList<>();
    final String[] strings = applicableToString.split(",");
    for (String s : strings){
        result.add(LeaseItemType.valueOf(s));
    }
    return result;
}
 
Example 12
Source File: OrderRepository_Test.java    From estatio with Apache License 2.0 5 votes vote down vote up
@Test
public void generateNextOrderNumber_skips_when_used() throws Exception {
    // given
    final Organisation buyerParty = new Organisation();

    OrderRepository orderRepository = new OrderRepository() {
        // hacky way of mocking existing orders with future increments of the numerator in the order number
        @Programmatic
        public List<Order> findByBuyerAndBuyerOrderNumber(
                final Organisation buyer,
                final BigInteger buyerOrderNumber) {
            return buyer.equals(buyerParty) && (buyerOrderNumber.equals(new BigInteger("2")) || buyerOrderNumber.equals(new BigInteger("3"))) ? Lists.newArrayList(order) : Lists.emptyList();
        }
    };

    orderRepository.numeratorForOrdersRepository = mockNumeratorForOrdersRepository;

    final Numerator numerator = new Numerator();
    numerator.setLastIncrement(new BigInteger("0"));
    numerator.setFormat("%04d");

    // expecting
    context.checking(new Expectations() {{
        // first generate call
        oneOf(mockNumeratorForOrdersRepository).findOrCreateNumerator("/ITA", buyerParty, "%04d");
        will(returnValue(numerator));

        // second generate call
        oneOf(mockNumeratorForOrdersRepository).findOrCreateNumerator("/ITA", buyerParty, "%04d");
        will(returnValue(numerator));
    }});

    // when
    final String nextIncrementIsAvailable = orderRepository.generateNextOrderNumber(buyerParty, "/ITA");
    final String skipsOneIncrement = orderRepository.generateNextOrderNumber(buyerParty, "/ITA");

    // then
    assertThat(nextIncrementIsAvailable).isEqualTo("0001"); // first increment is happily available
    assertThat(skipsOneIncrement).isEqualTo("0004"); // but orders with the next two increments already exist
}
 
Example 13
Source File: EthGetFilterChangesIntegrationTest.java    From besu with Apache License 2.0 4 votes vote down vote up
@Test
public void shouldReturnEmptyArrayIfNoNewBlocks() {
  final String filterId = filterManager.installBlockFilter();

  assertThatFilterExists(filterId);

  final JsonRpcRequestContext request = requestWithParams(String.valueOf(filterId));
  final JsonRpcSuccessResponse expected = new JsonRpcSuccessResponse(null, Lists.emptyList());
  final JsonRpcResponse actual = method.response(request);

  assertThat(actual).isEqualToComparingFieldByField(expected);

  filterManager.uninstallFilter(filterId);

  assertThatFilterDoesNotExist(filterId);
}
 
Example 14
Source File: VoteTallyCacheTestBase.java    From besu with Apache License 2.0 4 votes vote down vote up
protected Block createEmptyBlock(final long blockNumber, final Hash parentHash) {
  headerBuilder.number(blockNumber).parentHash(parentHash).coinbase(AddressHelpers.ofValue(0));
  return new Block(
      headerBuilder.buildHeader(), new BlockBody(Lists.emptyList(), Lists.emptyList()));
}
 
Example 15
Source File: PermissioningJsonRpcRequestFactory.java    From besu with Apache License 2.0 4 votes vote down vote up
Request<?, GetNodesWhitelistResponse> getNodesWhitelist() {
  return new Request<>(
      "perm_getNodesAllowlist", Lists.emptyList(), web3jService, GetNodesWhitelistResponse.class);
}