Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

246
Views
probar si una colección tiene exactamente un elemento que coincida con un predicado

Con Assertj , puedo usar anyMatch para probar si una colección tiene al menos un elemento que coincida con un predicado, por ejemplo

 var list = List.of("abc", "xyz") assertThat(list).anyMatch(element -> element.endsWith("xyz"));

Pero, ¿cómo pruebo si una colección tiene exactamente un elemento que coincide con un predicado?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

¿Qué hay de usar el filtro? https://github.com/assertj/assertj-core/blob/9eceff23e5b019af3d09c3e9bbc58126d51c02b6/src/main/java/org/assertj/core/api/AbstractIterableAssert.java#L3283

 var list = List.of("a", "b", "c!"); assertThat(list) .filteredOn(element -> element.endsWith("!")) .hasSize(1);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!