@Test public void save_persists_value_in_varchar_if_4000() { when(system2.now()).thenReturn(DATE_1); underTest.save(dbSession, A_KEY, VALUE_SIZE_4000); assertThatInternalProperty(A_KEY) .hasTextValue(VALUE_SIZE_4000) .hasCreatedAt(DATE_1); }
@Test public void save_persists_value_in_varchar_if_less_than_4000() { when(system2.now()).thenReturn(DATE_2); underTest.save(dbSession, A_KEY, VALUE_SMALL); assertThatInternalProperty(A_KEY) .hasTextValue(VALUE_SMALL) .hasCreatedAt(DATE_2); }
@Test public void saveAsEmpty_persist_property_without_textvalue_nor_clob_value() { when(system2.now()).thenReturn(DATE_2); underTest.saveAsEmpty(dbSession, A_KEY); assertThatInternalProperty(A_KEY) .isEmpty() .hasCreatedAt(DATE_2); }
@Test public void save_persists_new_value_in_clob_if_more_than_4000_when_old_one_was_in_clob() { when(system2.now()).thenReturn(DATE_1, DATE_2); String oldValue = VALUE_SIZE_4001 + "blabla"; underTest.save(dbSession, A_KEY, oldValue); assertThatInternalProperty(A_KEY) .hasClobValue(oldValue) .hasCreatedAt(DATE_1); underTest.save(dbSession, A_KEY, VALUE_SIZE_4001); assertThatInternalProperty(A_KEY) .hasClobValue(VALUE_SIZE_4001) .hasCreatedAt(DATE_2); }
@Test public void saveAsEmpty_persist_property_without_textvalue_nor_clob_value_when_old_value_was_in_varchar() { when(system2.now()).thenReturn(DATE_1, DATE_2); underTest.save(dbSession, A_KEY, VALUE_SMALL); assertThatInternalProperty(A_KEY) .hasTextValue(VALUE_SMALL) .hasCreatedAt(DATE_1); underTest.saveAsEmpty(dbSession, A_KEY); assertThatInternalProperty(A_KEY) .isEmpty() .hasCreatedAt(DATE_2); }
@Test public void save_persists_value_in_varchar_if_more_than_4000() { when(system2.now()).thenReturn(DATE_2); underTest.save(dbSession, A_KEY, VALUE_SIZE_4001); assertThatInternalProperty(A_KEY) .hasClobValue(VALUE_SIZE_4001) .hasCreatedAt(DATE_2); }
@Test public void save_persists_new_value_in_varchar_if_4000_when_old_one_was_in_varchar() { when(system2.now()).thenReturn(DATE_1, DATE_2); underTest.save(dbSession, A_KEY, VALUE_SMALL); assertThatInternalProperty(A_KEY) .hasTextValue(VALUE_SMALL) .hasCreatedAt(DATE_1); underTest.save(dbSession, A_KEY, VALUE_SIZE_4000); assertThatInternalProperty(A_KEY) .hasTextValue(VALUE_SIZE_4000) .hasCreatedAt(DATE_2); }
@Test public void save_persists_new_value_in_clob_if_more_than_4000_when_old_one_was_in_varchar() { when(system2.now()).thenReturn(DATE_1, DATE_2); underTest.save(dbSession, A_KEY, VALUE_SMALL); assertThatInternalProperty(A_KEY) .hasTextValue(VALUE_SMALL) .hasCreatedAt(DATE_1); underTest.save(dbSession, A_KEY, VALUE_SIZE_4001); assertThatInternalProperty(A_KEY) .hasClobValue(VALUE_SIZE_4001) .hasCreatedAt(DATE_2); }
@Test public void save_persists_new_value_in_varchar_if_less_than_4000_when_old_one_was_in_clob() { when(system2.now()).thenReturn(DATE_1, DATE_2); underTest.save(dbSession, A_KEY, VALUE_SIZE_4001); assertThatInternalProperty(A_KEY) .hasClobValue(VALUE_SIZE_4001) .hasCreatedAt(DATE_1); underTest.save(dbSession, A_KEY, VALUE_SMALL); assertThatInternalProperty(A_KEY) .hasTextValue(VALUE_SMALL) .hasCreatedAt(DATE_2); }
@Test public void saveAsEmpty_persist_property_without_textvalue_nor_clob_value_when_old_value_was_in_clob() { when(system2.now()).thenReturn(DATE_2, DATE_1); underTest.save(dbSession, A_KEY, VALUE_SIZE_4001); assertThatInternalProperty(A_KEY) .hasClobValue(VALUE_SIZE_4001) .hasCreatedAt(DATE_2); underTest.saveAsEmpty(dbSession, A_KEY); assertThatInternalProperty(A_KEY) .isEmpty() .hasCreatedAt(DATE_1); }