@Test public void setProperty_insert() { setupData("insert"); dao.setProperty(new PropertyDto().setKey("global.key").setValue("new_global")); dao.setProperty( new PropertyDto().setKey("project.key").setResourceId(10L).setValue("new_project")); dao.setProperty(new PropertyDto().setKey("user.key").setUserId(100L).setValue("new_user")); checkTables("insert", "properties"); }
@Test public void shouldFindUserIdsForFavouriteResource() { setupData("shouldFindUserIdsForFavouriteResource"); List<String> userIds = dao.findUserIdsForFavouriteResource(2L); assertThat(userIds.size(), is(2)); assertThat(userIds, hasItems("user3", "user4")); }
@Test public void deleteGlobalProperty() { setupData("deleteGlobalProperty"); dao.deleteGlobalProperty("to_be_deleted"); checkTables("deleteGlobalProperty", "properties"); }
@Test public void deleteGlobalProperties() { setupData("deleteGlobalProperties"); dao.deleteGlobalProperties(); checkTables("deleteGlobalProperties", "properties"); }
@Test public void updateGlobalProperties() { setupData("updateGlobalProperties"); dao.saveGlobalProperties(ImmutableMap.of("to_be_updated", "updated")); checkTable( "updateGlobalProperties", "properties", "prop_key", "text_value", "resource_id", "user_id"); }
@Test public void selectProjectProperties() { setupData("selectProjectProperties"); List<PropertyDto> properties = dao.selectProjectProperties("org.struts:struts"); assertThat(properties.size(), is(1)); PropertyDto first = properties.get(0); assertThat(first.getKey(), is("struts.one")); assertThat(first.getValue(), is("one")); }
@Test public void selectGlobalProperties() { setupData("selectGlobalProperties"); List<PropertyDto> properties = dao.selectGlobalProperties(); assertThat(properties.size(), is(2)); PropertyDto first = findById(properties, 1); assertThat(first.getKey(), is("global.one")); assertThat(first.getValue(), is("one")); PropertyDto second = findById(properties, 2); assertThat(second.getKey(), is("global.two")); assertThat(second.getValue(), is("two")); }