/** * Saves the specified property and its value. * <p> * If {@link PropertyDto#getValue()} is {@code null} or empty, the properties is persisted as empty. * </p> * * @throws IllegalArgumentException if {@link PropertyDto#getKey()} is {@code null} or empty */ public void saveProperty(DbSession session, PropertyDto property) { save(getMapper(session), property.getKey(), property.getUserId(), property.getResourceId(), property.getValue()); }
/** * Delete either global, user, component or component per user properties. * <p>Behaves in exactly the same way as {@link #selectByQuery(PropertyQuery, DbSession)} but deletes rather than * selects</p> * * Used by Governance. */ public int deleteByQuery(DbSession dbSession, PropertyQuery query) { return getMapper(dbSession).deleteByQuery(query); }
public int delete(DbSession dbSession, PropertyDto dto) { return getMapper(dbSession).delete(dto.getKey(), dto.getUserId(), dto.getResourceId()); }
@CheckForNull public PropertyDto selectProjectProperty(DbSession dbSession, long componentId, String propertyKey) { return getMapper(dbSession).selectByKey(new PropertyDto().setKey(propertyKey).setResourceId(componentId)); }
private PropertyDto newPropertyDto(String projectKey1, String projectValue1) { return new PropertyDto() .setKey(projectKey1) .setValue(projectValue1); } }
@Test public void remove_global_setting_even_if_not_defined() { logInAsSystemAdministrator(); propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one")); executeRequestOnGlobalSetting("foo"); assertGlobalPropertyDoesNotExist("foo"); }
@Test public void selectProjectProperty() { insertProperty("project.one", "one", 10L, null); PropertyDto property = underTest.selectProjectProperty(10L, "project.one"); assertThatDto(property) .hasKey("project.one") .hasResourceId(10L) .hasNoUserId() .hasValue("one"); }
public PropertyDtoAssert hasNoResourceId() { isNotNull(); if (actual.getResourceId() != null) { failWithMessage("Expected PropertyDto to have resourceId to be null but was <%s>", actual.getResourceId()); } return this; }
public PropertyDtoAssert hasNoUserId() { isNotNull(); if (actual.getUserId() != null) { failWithMessage("Expected PropertyDto to have userId to be null but was <%s>", actual.getUserId()); } return this; }
public List<PropertyDto> selectByQuery(PropertyQuery query, DbSession session) { return getMapper(session).selectByQuery(query); }
public void deleteGlobalProperty(String key, DbSession session) { getMapper(session).deleteGlobalProperty(key); }
public List<PropertyDto> selectProjectProperties(DbSession session, String projectKey) { return getMapper(session).selectProjectProperties(projectKey); }
public void deleteProjectProperty(String key, Long projectId, DbSession session) { getMapper(session).deleteProjectProperty(key, projectId); }
public List<PropertyDto> selectGlobalProperties(DbSession session) { return getMapper(session).selectGlobalProperties(); }
public void deleteProjectProperties(String key, String value, DbSession session) { getMapper(session).deleteProjectProperties(key, value); }
public PropertiesRowAssert hasNoUserId() { isNotNull(); if (actual.getUserId() != null) { failWithMessage("Expected PropertiesRow to have column USER_ID to be null but was <%s>", actual.getUserId()); } return this; }
public PropertiesRowAssert hasNoResourceId() { isNotNull(); if (actual.getResourceId() != null) { failWithMessage("Expected PropertiesRow to have column RESOURCE_ID to be null but was <%s>", actual.getResourceId()); } return this; }
@CheckForNull public PropertyDto selectGlobalProperty(DbSession session, String propertyKey) { return getMapper(session).selectByKey(new PropertyDto().setKey(propertyKey)); }
public PropertyDtoAssert hasResourceId(long expected) { isNotNull(); if (!Objects.equals(actual.getResourceId(), expected)) { failWithMessage("Expected PropertyDto to have resourceId to be <%s> but was <%s>", true, actual.getResourceId()); } return this; }
public PropertiesRowAssert hasUserId(int expected) { isNotNull(); if (!Objects.equals(actual.getUserId(), expected)) { failWithMessage("Expected PropertiesRow to have column USER_ID to be <%s> but was <%s>", true, actual.getUserId()); } return this; }