@Test public void shouldBulkUpdateKey() { dbTester.prepareDbUnit(getClass(), "shared.xml"); dao.bulkUpdateKey(1, "org.struts", "org.apache.struts"); dbTester.assertDbUnit(getClass(), "shouldBulkUpdateKey-result.xml", "projects"); }
@Test public void shouldNotUpdateAllSubmodules() { dbTester.prepareDbUnit(getClass(), "shouldNotUpdateAllSubmodules.xml"); dao.bulkUpdateKey(1, "org.struts", "org.apache.struts"); dbTester.assertDbUnit(getClass(), "shouldNotUpdateAllSubmodules-result.xml", "projects"); }
@Test public void shouldUpdateKey() { dbTester.prepareDbUnit(getClass(), "shared.xml"); dao.updateKey(2, "struts:core"); dbTester.assertDbUnit(getClass(), "shouldUpdateKey-result.xml", "projects"); }
@Test public void shouldBulkUpdateKeyOnOnlyOneSubmodule() { dbTester.prepareDbUnit(getClass(), "shared.xml"); dao.bulkUpdateKey(1, "struts-ui", "struts-web"); dbTester.assertDbUnit( getClass(), "shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml", "projects"); }
@Test public void shouldFailBulkUpdateKeyIfKeyAlreadyExist() { dbTester.prepareDbUnit(getClass(), "shared.xml"); thrown.expect(IllegalStateException.class); thrown.expectMessage( "Impossible to update key: a resource with \"foo:struts-core\" key already exists."); dao.bulkUpdateKey(1, "org.struts", "foo"); }
@Test public void shouldNotUpdateKey() { dbTester.prepareDbUnit(getClass(), "shared.xml"); thrown.expect(IllegalStateException.class); thrown.expectMessage( "Impossible to update key: a resource with \"org.struts:struts-ui\" key already exists."); dao.updateKey(2, "org.struts:struts-ui"); }
@Test public void shouldCheckModuleKeysBeforeRenaming() { dbTester.prepareDbUnit(getClass(), "shared.xml"); Map<String, String> checkResults = dao.checkModuleKeysBeforeRenaming(1, "org.struts", "foo"); assertThat(checkResults.size()).isEqualTo(3); assertThat(checkResults.get("org.struts:struts")).isEqualTo("foo:struts"); assertThat(checkResults.get("org.struts:struts-core")).isEqualTo("#duplicate_key#"); assertThat(checkResults.get("org.struts:struts-ui")).isEqualTo("foo:struts-ui"); }