Package java.util

Examples of java.util.Map


    Collection collection = new ArrayList();
    collection.add(new DomainClass(1));
    collection.add(new DomainClass(3));
    collection.add(new DomainClass(4));

    Map map = handler.createMap(collection);
    assert map instanceof HashMap;

    Object firstKey = map.keySet().iterator().next();
    assert firstKey instanceof Integer;

    Object value = map.get(firstKey);
    assert value instanceof DomainClass;

    System.out.print(map);
  }
View Full Code Here


    Collection collection = new ArrayList();
    collection.add(new DomainClass());
    collection.add(new DomainClass());
    collection.add(new DomainClass());

    Map map = handler.createMap(collection);
    assert map.size() == 1;
    assert map.keySet().iterator().next().equals(0);
  }
View Full Code Here

    Collection collection = new ArrayList();
    collection.add(new DomainClass(1));
    collection.add(new DomainClass(3));
    collection.add(new DomainClass(4));
    Map map = handler.getPropertyAsMap(collection);

    assert map.size() == 3;
    assert map instanceof HashMap;

    Object firstKey = map.keySet().iterator().next();
    assert firstKey instanceof Integer;

    Object value = map.get(firstKey);
    assert value instanceof DomainClass;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testValidate() throws ConversionException
  {

    Map validators = createStrictMock(Map.class);
    Set keys = createStrictMock(Set.class);
    Iterator iterator = createStrictMock(Iterator.class);
    OrderedProperty op = createStrictMock(OrderedProperty.class);
    MethodValidators methodValidators = createStrictMock(MethodValidators.class);
    Converter converter = createStrictMock(Converter.class);

    Date sqlDate = Date.valueOf("1999-12-12");
    simpleForm.setDateValue("1999-12-12");
    ValidationInfo vi = new ValidationInfo(validators, handler, new DefaultConversionHandler());

    expect(validators.keySet()).andReturn(keys);
    expect(keys.iterator()).andReturn(iterator);
    expect(iterator.hasNext()).andReturn(true);
    expect(iterator.next()).andReturn(op);
    expect(validators.get(op)).andReturn(methodValidators);
    expect(methodValidators.getRequiresConversion()).andReturn(true);
    expect(methodValidators.getConverter()).andReturn(converter);
    expect(op.getPropertyName()).andReturn("dateValue");
    expect(converter.toTargetType("1999-12-12")).andReturn(sqlDate);
    expect(methodValidators.getConverterType()).andReturn(sqlDate.getClass());
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testBadType() throws ConversionException
  {

    Map validators = createStrictMock(Map.class);
    Set keys = createStrictMock(Set.class);
    Iterator iterator = createStrictMock(Iterator.class);
    OrderedProperty op = createStrictMock(OrderedProperty.class);
    MethodValidators methodValidators = createStrictMock(MethodValidators.class);
    Converter converter = createStrictMock(Converter.class);

    Date sqlDate = Date.valueOf("1999-12-12");
    simpleForm.setDateValue("1999-12-12");
    ValidationInfo vi = new ValidationInfo(validators, handler, new DefaultConversionHandler());

    expect(validators.keySet()).andReturn(keys);
    expect(keys.iterator()).andReturn(iterator);
    expect(iterator.hasNext()).andReturn(true);
    expect(iterator.next()).andReturn(op);
    expect(validators.get(op)).andReturn(methodValidators);
    expect(methodValidators.getRequiresConversion()).andReturn(true);
    expect(methodValidators.getConverter()).andReturn(converter);
    expect(op.getPropertyName()).andReturn("dateValue");
    expect(converter.toTargetType("1999-12-12")).andReturn(sqlDate);
    expect(methodValidators.getConverterType()).andReturn(String.class);
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testValidateNull() throws ConversionException
  {

    Map validators = createStrictMock(Map.class);
    Set keys = createStrictMock(Set.class);
    Iterator iterator = createStrictMock(Iterator.class);
    OrderedProperty op = createStrictMock(OrderedProperty.class);
    MethodValidators methodValidators = createStrictMock(MethodValidators.class);
    Converter converter = createStrictMock(Converter.class);

    ValidationInfo vi = new ValidationInfo(validators, handler, new DefaultConversionHandler());

    expect(validators.keySet()).andReturn(keys);
    expect(keys.iterator()).andReturn(iterator);
    expect(iterator.hasNext()).andReturn(true);
    expect(iterator.next()).andReturn(op);
    expect(validators.get(op)).andReturn(methodValidators);
    expect(methodValidators.getRequiresConversion()).andReturn(true);
    expect(methodValidators.getConverter()).andReturn(converter);
    expect(op.getPropertyName()).andReturn("dateValue");
    expect(converter.toTargetType(null)).andReturn(null);
    expect(iterator.hasNext()).andReturn(false);
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void testConversionFailure() throws ConversionException
  {

    Map validators = createStrictMock(Map.class);
    Set keys = createStrictMock(Set.class);
    Iterator iterator = createStrictMock(Iterator.class);
    OrderedProperty op = createStrictMock(OrderedProperty.class);
    MethodValidators methodValidators = createStrictMock(MethodValidators.class);
    Converter converter = createStrictMock(Converter.class);

    ValidationInfo vi = new ValidationInfo(validators, handler, new DefaultConversionHandler());

    expect(validators.keySet()).andReturn(keys);
    expect(keys.iterator()).andReturn(iterator);
    expect(iterator.hasNext()).andReturn(true);
    expect(iterator.next()).andReturn(op);
    expect(validators.get(op)).andReturn(methodValidators);
    expect(methodValidators.getRequiresConversion()).andReturn(true);
    expect(methodValidators.getConverter()).andReturn(converter);
    expect(op.getPropertyName()).andReturn("dateValue");
    expect(converter.toTargetType(null)).andThrow(new ConversionRuntimeException(null));
    expect(iterator.hasNext()).andReturn(false);
View Full Code Here

    }

    public void testClone() {
        CaseInsensitiveMap map = new CaseInsensitiveMap(10);
        map.put("1", "1");
        Map cloned = (Map) map.clone();
        assertEquals(map.size(), cloned.size());
        assertSame(map.get("1"), cloned.get("1"));
    }
View Full Code Here

    assignAll(bean);
    return out();
  }
 
  protected void assignAll(Object bean) {
    Map p = getBeanProperties(bean);
    Iterator i = p.keySet().iterator();
    while (i.hasNext()) {
      String key = (String) i.next();
      assign(key.toUpperCase(), "" + p.get(key));
    }
  }
View Full Code Here

    }
  
    //-------------------------------------------------------------------------
   
    public void testCaseInsensitive() {
        Map map = new CaseInsensitiveMap();
        map.put("One", "One");
        map.put("Two", "Two");
        assertEquals("One", (String) map.get("one"));
        assertEquals("One", (String) map.get("oNe"));
        map.put("two", "Three");
        assertEquals("Three", (String) map.get("Two"));
    }
View Full Code Here

TOP

Related Classes of java.util.Map

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.