*/
package org.sonar.core.properties;
-import com.google.common.collect.Maps;
+import com.google.common.collect.ImmutableMap;
import org.junit.Before;
import org.junit.Test;
import org.sonar.core.persistence.AbstractDaoTestCase;
import java.util.List;
-import java.util.TreeMap;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.is;
}
@Test
- public void saveGlobalProperties() {
- setupData("saveGlobalProperties");
+ public void insertGlobalProperties() {
+ setupData("insertGlobalProperties");
- TreeMap<String, String> props = Maps.newTreeMap();
- props.put("to_be_inserted", "inserted");
- props.put("to_be_updated", "updated");
- dao.saveGlobalProperties(props);
+ dao.saveGlobalProperties(ImmutableMap.of("to_be_inserted", "inserted"));
- checkTable("saveGlobalProperties", "properties", "prop_key", "text_value", "resource_id", "user_id");
+ checkTable("insertGlobalProperties", "properties", "prop_key", "text_value", "resource_id", "user_id");
+ }
+
+ @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");
}
private PropertyDto findById(List<PropertyDto> properties, int id) {
+++ /dev/null
-<dataset>
-
- <!-- global -->
- <!--<properties id="1" prop_key="to_be_updated" text_value="old value" resource_id="[null]" user_id="[null]"/>-->
- <properties id="2" prop_key="to_not_change" text_value="xxx" resource_id="[null]" user_id="[null]"/>
-
- <!-- project - do not update this project property that has the same key -->
- <properties id="3" prop_key="to_be_updated" text_value="new_project" resource_id="10" user_id="[null]"/>
-
- <!-- user -->
- <properties id="4" prop_key="user.key" text_value="new_user" resource_id="[null]" user_id="100"/>
-
-
- <properties id="5" prop_key="to_be_inserted" text_value="inserted" resource_id="[null]" user_id="[null]"/>
- <properties id="6" prop_key="to_be_updated" text_value="updated" resource_id="[null]" user_id="[null]"/>
-
-
-</dataset>
\ No newline at end of file
+++ /dev/null
-<dataset>
-
- <!-- global -->
- <properties id="1" prop_key="to_be_updated" text_value="old value" resource_id="[null]" user_id="[null]"/>
- <properties id="2" prop_key="to_not_change" text_value="xxx" resource_id="[null]" user_id="[null]"/>
-
- <!-- project - do not update this project property that has the same key -->
- <properties id="3" prop_key="to_be_updated" text_value="new_project" resource_id="10" user_id="[null]"/>
-
- <!-- user -->
- <properties id="4" prop_key="user.key" text_value="new_user" resource_id="[null]" user_id="100"/>
-
-</dataset>
--- /dev/null
+<dataset>
+
+ <!-- global -->
+ <!--<properties prop_key="to_be_updated" text_value="old value" resource_id="[null]" user_id="[null]"/>-->
+ <properties prop_key="to_not_change" text_value="xxx" resource_id="[null]" user_id="[null]"/>
+
+ <!-- project - do not update this project property that has the same key -->
+ <properties prop_key="to_be_updated" text_value="new_project" resource_id="10" user_id="[null]"/>
+
+
+ <properties prop_key="to_be_updated" text_value="updated" resource_id="[null]" user_id="[null]"/>
+</dataset>