ObjectToCellValueConverter implements ToCellValueConverter { @Override public CellValue from(final Object o) { if (o == null) { return VoidValue.INSTANCE; } else if (o instanceof String) { return new StringValue((String) o); } else if (o instanceof Text) { return new TextValue((Text) o); } else if (o instanceof Number) { return new FloatValue((Number) o); } else if (o instanceof Boolean) { return new BooleanValue((Boolean) o); } else if (o instanceof Date) { return new DateValue((Date) o); } else if (o instanceof Calendar) { return new DateValue(((Calendar) o).getTime()); } else if (o instanceof CellValue) { return (CellValue) o; } else { return new StringValue(o.toString()); } } ObjectToCellValueConverter(final String currency); @Override CellValue from(final Object o); @Override CellValue from(final CellType type, final Object o);  }
@Test public void testFromNull() { Assert.assertEquals(VoidValue.INSTANCE, this.converter.from(null)); }
@Test public void testFromHintNull() throws FastOdsException { Assert.assertEquals(VoidValue.INSTANCE, this.converter.from(CellType.VOID, null)); }
@Test(expected = FastOdsException.class) public void testFromHintFailNull() throws FastOdsException { Assert.assertEquals(VoidValue.INSTANCE, this.converter.from(CellType.FLOAT, null)); }
@Test public void testFromString() { Assert.assertEquals(new StringValue(FAST_ODS), this.converter.from(FAST_ODS)); }
@Test public void testFromHintString() throws FastOdsException { Assert.assertEquals(new StringValue("10"), this.converter.from(CellType.STRING, 10)); }
@Test(expected = FastOdsException.class) public void testFromHintFailString() throws FastOdsException { this.converter.from(CellType.VOID, FAST_ODS); }
@Test public void testFromText() { final Text content = Text.content(FAST_ODS); Assert.assertEquals(new TextValue(content), this.converter.from(content)); }
@Test public void testFromHintText() throws FastOdsException { final Text content = Text.content(FAST_ODS); Assert.assertEquals(new TextValue(content), this.converter.from(CellType.STRING, content)); }
@Test(expected = FastOdsException.class) public void testFromHintFailText() throws FastOdsException { this.converter.from(CellType.VOID, Text.content(FAST_ODS)); }
@Test public void testFromNumber() { Assert.assertEquals(new FloatValue(8.5), this.converter.from(8.5)); }
@Test public void testFromHintNumber() throws FastOdsException { Assert.assertEquals(new FloatValue(8.5), this.converter.from(CellType.FLOAT, 8.5)); }
@Test(expected = FastOdsException.class) public void testFromHintFailNumber() throws FastOdsException { this.converter.from(CellType.VOID, 8.5); }
@Test public void testFromBoolean() { Assert.assertEquals(new BooleanValue(true), this.converter.from(true)); }
@Test public void testFromHintBoolean() throws FastOdsException { Assert.assertEquals(new BooleanValue(true), this.converter.from(CellType.BOOLEAN, true)); }
@Test(expected = FastOdsException.class) public void testFromHintFailBoolean() throws FastOdsException { this.converter.from(CellType.VOID, true); }
@Test public void testFromDate() { Assert.assertEquals(new DateValue(DATE_123), this.converter.from(DATE_123)); }
@Test public void testFromHintDate() throws FastOdsException { Assert.assertEquals(new DateValue(DATE_123), this.converter.from(CellType.DATE, 123)); }
@Test(expected = FastOdsException.class) public void testFromHintFailDate() throws FastOdsException { this.converter.from(CellType.VOID, DATE_123); }
@Test public void testFromCalendar() { Assert.assertEquals(new DateValue(DATE_456000), this.converter.from(CALENDAR_456)); }
@Test public void testFromHintCalendar() throws FastOdsException { Assert.assertEquals(new DateValue(DATE_456000), this.converter.from(CellType.DATE, CALENDAR_456)); }
@Test(expected = FastOdsException.class) public void testFromHintFailCalendar() throws FastOdsException { this.converter.from(CellType.VOID, CALENDAR_456); }
@Test public void testFromHintCurrency() throws FastOdsException { Assert.assertEquals(new CurrencyValue(5, "USD"), this.converter.from(CellType.CURRENCY, 5)); }
@Test(expected = FastOdsException.class) public void testFromHintFailCurrency() throws FastOdsException { this.converter.from(CellType.CURRENCY, "0.47"); }
@Test public void testFromHintPercentage() throws FastOdsException { Assert.assertEquals(new PercentageValue(0.46), this.converter.from(CellType.PERCENTAGE, 0.46)); }
@Test(expected = FastOdsException.class) public void testFromHintFailPercentage() throws FastOdsException { this.converter.from(CellType.PERCENTAGE, "0.49"); }
@Test public void testFromHintTime() throws FastOdsException { Assert.assertEquals(new TimeValue(false, 0, 0, 0, 0, 0, 165), this.converter.from(CellType.TIME, 165 * 1000)); }
@Test(expected = FastOdsException.class) public void testFromHintFailTime() throws FastOdsException { this.converter.from(CellType.TIME, "165"); }
@Test public void testFromCellValue() throws FastOdsException { Assert.assertEquals(new FloatValue(10), this.converter.from(FloatValue.from(10))); }
@Test public void testFromHintCellValue() throws FastOdsException { Assert.assertEquals(new FloatValue(10.0), this.converter.from(CellType.FLOAT, FloatValue.from(10.0))); }
@Test(expected = FastOdsException.class) public void testFromHintFailCellValue() throws FastOdsException { this.converter.from(CellType.VOID, FloatValue.from(10)); }