// do nothing
}
- @Override
- public void deleteGlobalProperties() {
- // do nothing
- }
-
@Override
public void deleteGlobalProperty(String key, DbSession session) {
// do nothing
// do nothing
}
- @Override
- public void deleteAllProperties(String key) {
- // do nothing
- }
-
@Override
public void insertGlobalProperties(Map<String, String> properties) {
// do nothing
// do nothing
}
- @Override
- public void updateProperties(String key, String oldValue, String newValue) {
- // do nothing
- }
-
- @Override
- public void updateProperties(String key, String oldValue, String newValue, DbSession session) {
- // do nothing
- }
-
@Override
public void setProperty(org.sonar.core.properties.PropertyDto property) {
// do nothing
}
- @Test
- public void deleteGlobalProperties() {
- underTest.deleteGlobalProperties();
-
- assertNoInteraction();
-
- }
-
@Test
public void deleteGlobalProperty() {
underTest.deleteGlobalProperty(null);
}
- @Test
- public void deleteAllProperties() {
- underTest.deleteAllProperties(null);
-
- assertNoInteraction();
-
- }
-
@Test
public void insertGlobalProperties() {
underTest.insertGlobalProperties(null);
}
- @Test
- public void updateProperties() {
- underTest.updateProperties(null, null, null);
-
- assertNoInteraction();
-
- }
-
- @Test
- public void updateProperties1() {
- underTest.updateProperties(null, null, null, dbSession);
-
- assertNoInteraction();
-
- }
-
@Test
public void setProperty() {
underTest.setProperty(oldPropertyDto);
}
}
- public void deleteGlobalProperties() {
- try (DbSession session = mybatis.openSession(false)) {
- getMapper(session).deleteGlobalProperties();
- session.commit();
- }
- }
-
public void deleteGlobalProperty(String key, DbSession session) {
getMapper(session).deleteGlobalProperty(key);
}
}
}
- public void deleteAllProperties(String key) {
- try (DbSession session = mybatis.openSession(false)) {
- getMapper(session).deleteAllProperties(key);
- session.commit();
- }
- }
-
public void insertGlobalProperties(Map<String, String> properties) {
try (DbSession session = mybatis.openSession(false)) {
PropertiesMapper mapper = getMapper(session);
}
}
- /**
- * Update all properties (global and projects ones) with a given key and value to a new value
- */
- public void updateProperties(String key, String oldValue, String newValue) {
- try (DbSession session = mybatis.openSession(false)) {
- updateProperties(key, oldValue, newValue, session);
- session.commit();
- }
- }
-
- public void updateProperties(String key, String oldValue, String newValue, DbSession session) {
- getMapper(session).updateProperties(key, oldValue, newValue);
- }
-
private static PropertiesMapper getMapper(DbSession session) {
return session.getMapper(PropertiesMapper.class);
}
List<PropertyDto> selectProjectProperties(String resourceKey);
- List<PropertyDto> selectProjectPropertiesByResourceId(Long resourceId);
-
- List<PropertyDto> selectSetOfResourceProperties(@Param("rId") Long projectId, @Param("propKeys") List<String> propertyKeys);
-
PropertyDto selectByKey(PropertyDto key);
List<PropertyDto> selectByKeys(@Param("keys") List<String> keys, @Nullable @Param("componentId") Long componentId);
void deleteGlobalProperty(String key);
- void deleteAllProperties(String key);
-
- void deleteGlobalProperties();
-
void renamePropertyKey(@Param("oldKey") String oldKey, @Param("newKey") String newKey);
- void updateProperties(@Param("key") String key, @Param("oldValue") String oldValue, @Param("newValue") String newValue);
}
where p.resource_id=r.id and p.user_id is null and r.kee=#{resourceKey}
</select>
- <select id="selectProjectPropertiesByResourceId" parameterType="Long" resultType="Property">
- select p.id as id, p.prop_key as "key", p.text_value as value, p.resource_id as resourceId, p.user_id as userId
- from properties p
- where p.resource_id=#{resourceId} and p.user_id is null
- </select>
-
<select id="selectDescendantModuleProperties" parameterType="String" resultType="Property">
SELECT prop.id as id, prop.prop_key as "key", prop.text_value as value, prop.resource_id as resourceId, prop.user_id
as userId
WHERE prop.user_id IS NULL
</select>
- <select id="selectSetOfResourceProperties" parameterType="map" resultType="Property">
- select p.id as id, p.prop_key as "key", p.text_value as value, p.resource_id as resourceId, p.user_id as userId
- from properties p
- where p.resource_id=#{rId} and p.prop_key in
- <foreach item="propKey" index="index" collection="propKeys" open="(" separator="," close=")">#{propKey}</foreach>
- </select>
-
<select id="selectByKey" parameterType="map" resultType="Property">
select p.id as id, p.prop_key as "key", p.text_value as value, p.resource_id as resourceId, p.user_id as userId
from properties p
delete from properties where resource_id is null and user_id is null
</delete>
- <delete id="deleteAllProperties" parameterType="string">
- delete from properties where prop_key=#{id}
- </delete>
-
<update id="renamePropertyKey" parameterType="map">
update properties set prop_key=#{newKey} where prop_key=#{oldKey}
</update>
- <update id="updateProperties" parameterType="map">
- update properties set text_value=#{newValue} where text_value LIKE #{oldValue} and prop_key=#{key}
- </update>
-
</mapper>
dbTester.assertDbUnit(getClass(), "delete_project_properties-result.xml", "properties");
}
- @Test
- public void deleteGlobalProperties() {
- dbTester.prepareDbUnit(getClass(), "deleteGlobalProperties.xml");
-
- underTest.deleteGlobalProperties();
-
- dbTester.assertDbUnit(getClass(), "deleteGlobalProperties-result.xml", "properties");
- }
-
@Test
public void deleteGlobalProperty() {
dbTester.prepareDbUnit(getClass(), "deleteGlobalProperty.xml");
dbTester.assertDbUnit(getClass(), "deleteGlobalProperty-result.xml", "properties");
}
- @Test
- public void deleteAllProperties() {
- dbTester.prepareDbUnit(getClass(), "deleteAllProperties.xml");
-
- underTest.deleteAllProperties("to_be_deleted");
-
- dbTester.assertDbUnit(getClass(), "deleteAllProperties-result.xml", "properties");
- }
-
@Test
public void insertGlobalProperties() {
dbTester.prepareDbUnit(getClass(), "insertGlobalProperties.xml");
underTest.renamePropertyKey(null, "foo");
}
- @Test
- public void updatePropertiesFromKeyAndValueToNewValue() {
- dbTester.prepareDbUnit(getClass(), "updatePropertiesFromKeyAndValueToNewValue.xml");
-
- underTest.updateProperties("sonar.profile.java", "Sonar Way", "Default");
-
- dbTester.assertDbUnitTable(getClass(), "updatePropertiesFromKeyAndValueToNewValue-result.xml", "properties", "prop_key", "text_value", "resource_id", "user_id");
- }
-
private PropertyDto findById(List<PropertyDto> properties, int id) {
for (PropertyDto property : properties) {
if (property.getId() == id) {