Code example for ImmutableSortedSet

Methods: iteratorsize

0
    public void testImmutableSortedSet( ObjectMapperTester<ImmutableSortedSet<Integer>> mapper ) {
        String json = mapper.write( ImmutableSortedSet.of( 5, 1, 2 ) );
        assertEquals( "[1,2,5]", json );
 
        ImmutableSortedSet<Integer> set = mapper.read( "[5,1,2]" );
        assertEquals( 3, set.size() );
        Iterator<Integer> it = set.iterator();
        assertEquals( Integer.valueOf( 1 ), it.next() );
        assertEquals( Integer.valueOf( 2 ), it.next() );
        assertEquals( Integer.valueOf( 5 ), it.next() );
    } 
 
    public void testImmutableMap( ObjectMapperTester<ImmutableMap<Integer, Boolean>> mapper ) {
        String json = mapper.write( ImmutableMap.of( 12, true, 4, false ) );
        assertEquals( "{\"12\":true,\"4\":false}", json );
 
        ImmutableMap<Integer, Boolean> map = mapper.read( json );
        assertEquals( 2, map.size() );
        assertEquals( Boolean.TRUE, map.get( Integer.valueOf( 12 ) ) );
        assertEquals( Boolean.FALSE, map.get( Integer.valueOf( 4 ) ) );