}
@Test
- public void insertOrUpdate() {
- setupData("insertOrUpdate");
+ public void should_update() {
+ setupData("update");
- // to be updated
ResourceDto project = new ResourceDto()
- .setKey("org.struts:struts").setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT)
- .setName("Struts").setLongName("Apache Struts").setLanguage("java").setDescription("MVC Framework")
- .setId(100L);
+ .setKey("org.struts:struts").setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT)
+ .setName("Struts").setLongName("Apache Struts").setLanguage("java").setDescription("MVC Framework")
+ .setId(1L);
+
+ dao.insertOrUpdate(project);
+
+ assertThat(project.getId()).isNotNull();
+ checkTables("update", "projects");
+ }
+
+ @Test
+ public void should_insert() {
+ setupData("insert");
- // to be inserted
ResourceDto file1 = new ResourceDto()
.setKey("org.struts:struts:org.struts.Action").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE)
.setLanguage("java").setName("Action").setLongName("org.struts.Action");
.setKey("org.struts:struts:org.struts.Filter").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE)
.setLanguage("java").setName("Filter").setLongName("org.struts.Filter");
- dao.insertOrUpdate(project, file1, file2);
+ dao.insertOrUpdate(file1, file2);
- assertThat(project.getId()).isNotNull();
assertThat(file1.getId()).isNotNull();
assertThat(file2.getId()).isNotNull();
- checkTables("insertOrUpdate", new String[]{"id"}, "projects");
+ checkTables("insert", "projects");
}
-
}
--- /dev/null
+<dataset>
+
+ <projects id="1" root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Action" name="Action"
+ description="[null]" long_name="org.struts.Action"
+ enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+
+ <projects id="2" root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Filter" name="Filter"
+ description="[null]" long_name="org.struts.Filter"
+ enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
+
+</dataset>
+++ /dev/null
-<dataset>
-
- <projects root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts"
- description="MVC Framework" long_name="Apache Struts"
- enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
-
- <projects root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Action" name="Action"
- description="[null]" long_name="org.struts.Action"
- enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
-
- <projects root_id="[null]" scope="FIL" qualifier="FIL" kee="org.struts:struts:org.struts.Filter" name="Filter"
- description="[null]" long_name="org.struts.Filter"
- enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" profile_id="[null]"/>
-
-</dataset>