Double brace (#1798)

* BAL-36 File size api in java and apache commons IO

* BAEL-282 grep in java - fixes after code review

* BAEL-519 Added support for disruptor library

* BAEL-519 Added support for disruptor library

* BAEL-519 Added support for disruptor library

* BAEL-519 Added support for disruptor library

* BAEL-519 Added support for disruptor library

* BAEL-519 Added support for disruptor library

* BAEL-519 Added support for disruptor

* BAEL-519 Moved all supporting classes to main source

* BAEL-519 Moved all supporting classes to main source

* BAEL-519 Moved asserts and test classes in test folder.

* BAEL-519 moved test related producer and consumer to src.

* BAEL-586 Guide to Guava BiMap.

* BAEL-587 formatted code.

* BAEL-519 LMAX Disruptor

* BAEL-587 resolved merge

* BAEL-587 Resolved merge

* BAEL-519 Removed disruptor link.

* BAEL-519 Reverted Guava changes

* RFQ-587 Added disruptor as a separate module.

* BAEL-519 Disruptor changes.

* BAEL-519 Removed disruptor from core-java module.

* BAEL-729 Expose additional information programmatically in /info
endpoint of actuator.

* BAEL-824 Usage of Double braces in Java.

* Deleted sample project

* updated test and names.
This commit is contained in:
Muhammed Almas 2017-05-08 00:34:35 +05:30 committed by Zeger Hendrikse
parent 0bcd8514cf
commit 46d9022879
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
package com.baeldung.java.doublebrace;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;
import static java.util.stream.Collectors.toSet;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class DoubleBraceTest {
@Test
public void whenInitializeSetWithoutDoubleBraces_containsElements() {
final Set<String> countries = new HashSet<String>();
countries.add("India");
countries.add("USSR");
countries.add("USA");
assertTrue(countries.contains("India"));
}
@Test
public void whenInitializeSetWithDoubleBraces_containsElements() {
final Set<String> countries = new HashSet<String>() {
{
add("India");
add("USSR");
add("USA");
}
};
assertTrue(countries.contains("India"));
}
@Test
public void whenInitializeUnmodifiableSetWithDoubleBrace_containsElements() {
final Set<String> countries = Collections.unmodifiableSet(Stream.of("India", "USSR", "USA").collect(toSet()));
assertTrue(countries.contains("India"));
}
}