}
}
+ public void deleteById(DbSession dbSession, long id) {
+ dbSession.getMapper(PropertiesMapper.class).deleteById(id);
+ }
+
public void deleteProjectProperty(String key, Long projectId) {
DbSession session = mybatis.openSession(false);
try {
void insert(PropertyDto property);
+ void deleteById(long id);
+
void deleteProjectProperty(@Param("key") String key, @Param("rId") Long resourceId);
void deleteProjectProperties(@Param("key") String key, @Param("value") String value);
VALUES (#{key}, #{resourceId}, #{userId}, #{value})
</insert>
+ <delete id="deleteById" parameterType="long">
+ delete from properties where id=#{id}
+ </delete>
+
<delete id="deleteProjectProperty" parameterType="map">
delete from properties where prop_key=#{key} and resource_id=#{rId} and user_id is null
</delete>
dbTester.assertDbUnit(getClass(), "insert-result.xml", "properties");
}
+ @Test
+ public void delete_property_by_id() {
+ dbTester.prepareDbUnit(getClass(), "delete.xml");
+
+ dao.deleteById(dbTester.getSession(), 1L);
+ dbTester.getSession().commit();
+
+ dbTester.assertDbUnit(getClass(), "delete-result.xml", "properties");
+ }
+
@Test
public void delete_project_property() {
dbTester.prepareDbUnit(getClass(), "delete_project_property.xml");
--- /dev/null
+<dataset>
+
+ <!-- global -->
+ <!--<properties id="1" prop_key="global.key" text_value="global" resource_id="[null]" user_id="[null]"/>-->
+
+ <!-- project -->
+ <properties id="2" prop_key="project.key" text_value="project" resource_id="10" user_id="[null]"/>
+
+ <!-- user -->
+ <properties id="3" prop_key="user.key" text_value="user" resource_id="[null]" user_id="100"/>
+
+ <!-- null value -->
+ <properties id="4" prop_key="null.value" text_value="not null" resource_id="[null]" user_id="[null]"/>
+</dataset>
--- /dev/null
+<dataset>
+
+ <!-- global -->
+ <properties id="1" prop_key="global.key" text_value="global" resource_id="[null]" user_id="[null]"/>
+
+ <!-- project -->
+ <properties id="2" prop_key="project.key" text_value="project" resource_id="10" user_id="[null]"/>
+
+ <!-- user -->
+ <properties id="3" prop_key="user.key" text_value="user" resource_id="[null]" user_id="100"/>
+
+ <!-- null value -->
+ <properties id="4" prop_key="null.value" text_value="not null" resource_id="[null]" user_id="[null]"/>
+</dataset>