public void testSimpleWithAutoSchema() throws Exception {
   CsvSchema schema = MAPPER.schemaFor(FiveMinuteUser.class);
   // NOTE: order different from above test (as per POJO def!)
   FiveMinuteUser user =
       MAPPER
           .reader(schema)
           .forType(FiveMinuteUser.class)
           .readValue("Joe,Josephson,MALE,true,AwE=\n");
   assertEquals("Joe", user.firstName);
   assertEquals("Josephson", user.lastName);
   assertEquals(Gender.MALE, user.getGender());
   assertTrue(user.isVerified());
   assertArrayEquals(new byte[] {3, 1}, user.getUserImage());
 }
  /** Test to verify that we can mix "untyped" access as Maps with schema information... */
  public void testSimpleAsMaps() throws Exception {
    CsvSchema schema = MAPPER.schemaFor(FiveMinuteUser.class);
    MappingIterator<Map<?, ?>> it =
        MAPPER.reader(schema).forType(Map.class).readValues("Joe,Smith,MALE,false,");
    assertTrue(it.hasNext());
    Map<?, ?> result = it.nextValue();
    assertEquals(5, result.size());
    assertEquals("Joe", result.get("firstName"));
    assertEquals("Smith", result.get("lastName"));
    assertEquals("MALE", result.get("gender"));
    assertEquals("false", result.get("verified"));
    assertEquals("", result.get("userImage"));

    assertFalse(it.hasNextValue());
    it.close();
  }
  public void testSimpleExplicitWithBOM() throws Exception {
    ObjectReader r = MAPPER.reader(SIMPLE_SCHEMA);
    r = r.forType(FiveMinuteUser.class);
    FiveMinuteUser user;

    ByteArrayOutputStream b = new ByteArrayOutputStream();

    // first, UTF-8 BOM:
    b.write(new byte[] {(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});
    b.write("Bob,Robertson,MALE,AQIDBAU=,false\n".getBytes("UTF-8"));
    b.close();

    user = r.readValue(b.toByteArray());
    String fn = user.firstName;

    if (!fn.equals("Bob")) {
      fail("Expected 'Bob' (3), got '" + fn + "' (" + fn.length() + ")");
    }
    assertEquals("Robertson", user.lastName);
    assertEquals(Gender.MALE, user.getGender());
    assertFalse(user.isVerified());
    assertArrayEquals(new byte[] {1, 2, 3, 4, 5}, user.getUserImage());
  }
 public void testSimpleExplicit() throws Exception {
   ObjectReader r = MAPPER.reader(SIMPLE_SCHEMA);
   _testSimpleExplicit(r, false);
   _testSimpleExplicit(r, true);
 }