Skip to content

Commit 14c3fa5

Browse files
committed
Fixed import
1 parent 233b022 commit 14c3fa5

File tree

1 file changed

+9
-36
lines changed

1 file changed

+9
-36
lines changed

tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLUpdateTest.java

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.ArrayList;
1919
import java.util.Arrays;
2020
import java.util.Collection;
21+
import java.util.HashMap;
2122
import java.util.List;
2223
import java.util.Map;
2324

@@ -49,20 +50,19 @@ public class SQLUpdateTest {
4950
public SQLUpdateTest(String iURL) {
5051
database = new ODatabaseDocumentTx(iURL);
5152
}
52-
53+
5354
@BeforeTest
5455
private void before() {
5556
database.open("admin", "admin");
5657
}
57-
58+
5859
@AfterTest
5960
private void after() {
60-
database.close();
61+
database.close();
6162
}
62-
63+
6364
@Test
6465
public void updateWithWhereOperator() {
65-
6666

6767
List<OClusterPosition> positions = getValidPositions(4);
6868

@@ -72,13 +72,10 @@ public void updateWithWhereOperator() {
7272

7373
Assert.assertEquals(records.intValue(), 3);
7474

75-
7675
}
7776

78-
7977
@Test
8078
public void updateWithWhereRid() {
81-
8279

8380
List<ODocument> result = database.command(new OCommandSQL("select @rid as rid from Profile where surname = 'Obama'")).execute();
8481

@@ -89,32 +86,26 @@ public void updateWithWhereRid() {
8986

9087
Assert.assertEquals(records.intValue(), 1);
9188

92-
9389
}
9490

9591
@Test(dependsOnMethods = "updateWithWhereOperator")
9692
public void updateCollectionsAddWithWhereOperator() {
97-
9893

9994
updatedRecords = (Integer) database.command(new OCommandSQL("update Account add addresses = #13:0")).execute();
10095

101-
10296
}
10397

10498
@Test(dependsOnMethods = "updateCollectionsAddWithWhereOperator")
10599
public void updateCollectionsRemoveWithWhereOperator() {
106-
107100

108101
final int records = (Integer) database.command(new OCommandSQL("update Account remove addresses = #13:0")).execute();
109102

110103
Assert.assertEquals(records, updatedRecords);
111104

112-
113105
}
114106

115107
@Test(dependsOnMethods = "updateCollectionsRemoveWithWhereOperator")
116108
public void updateCollectionsWithSetOperator() {
117-
118109

119110
List<ODocument> docs = database.query(new OSQLSynchQuery<ODocument>("select from Account"));
120111

@@ -136,12 +127,10 @@ public void updateCollectionsWithSetOperator() {
136127
database.save(loadedDoc);
137128
}
138129

139-
140130
}
141131

142132
@Test(dependsOnMethods = "updateCollectionsRemoveWithWhereOperator")
143133
public void updateMapsWithSetOperator() {
144-
145134

146135
ODocument doc = (ODocument) database
147136
.command(
@@ -170,12 +159,10 @@ public void updateMapsWithSetOperator() {
170159
Assert.assertEquals(entries.get("bla"), "zagzig");
171160
Assert.assertEquals(entries.get("testTestTEST"), "okOkOK");
172161

173-
174162
}
175163

176164
@Test(dependsOnMethods = "updateCollectionsRemoveWithWhereOperator")
177165
public void updateMapsWithPutOperatorAndWhere() {
178-
179166

180167
ODocument doc = (ODocument) database.command(
181168
new OCommandSQL(
@@ -201,38 +188,32 @@ public void updateMapsWithPutOperatorAndWhere() {
201188

202189
Assert.assertEquals(entries.get("one"), "two");
203190

204-
205191
}
206192

207193
@Test(dependsOnMethods = "updateCollectionsRemoveWithWhereOperator")
208194
public void updateAllOperator() {
209-
210195

211196
Long total = database.countClass("Profile");
212197

213198
Integer records = (Integer) database.command(new OCommandSQL("update Profile set sex = 'male'")).execute();
214199

215200
Assert.assertEquals(records.intValue(), total.intValue());
216201

217-
218202
}
219203

220204
@Test
221205
public void updateWithWildcards() {
222-
223206

224207
int updated = (Integer) database.command(new OCommandSQL("update Profile set sex = ? where sex = 'male' limit 1")).execute(
225208
"male");
226209

227210
Assert.assertEquals(updated, 1);
228211

229-
230212
}
231213

232214
@Test
233215
public void updateWithWildcardsOnSetAndWhere() {
234216

235-
236217
ODocument doc = new ODocument("Person");
237218
doc.field("name", "Raf");
238219
doc.field("city", "Torino");
@@ -261,23 +242,22 @@ public void updateWithWildcardsOnSetAndWhere() {
261242
database.command(updatecommand).execute("f", "Raf");
262243
checkUpdatedDoc(database, "Raf", "TORINO", "f");
263244

264-
265245
}
266246

267247
@Test
268-
public void updateWithNamedParameters(){
248+
public void updateWithNamedParameters() {
269249
ODocument doc = new ODocument("Data");
270250
doc.field("name", "Raf");
271251
doc.field("city", "Torino");
272252
doc.field("gender", "fmale");
273253
doc.save();
274254

275255
OCommandSQL updatecommand = new OCommandSQL("update Data set gender = :gender , city = :city where name = :name");
276-
Map<String,Object> params = new HashMap<String, Object>();
256+
Map<String, Object> params = new HashMap<String, Object>();
277257
params.put("gender", "f");
278258
params.put("city", "TOR");
279259
params.put("name", "Raf");
280-
260+
281261
database.command(updatecommand).execute(params);
282262
List<ODocument> result = database.query(new OSQLSynchQuery<Object>("select * from Data"));
283263
ODocument oDoc = result.get(0);
@@ -286,10 +266,7 @@ public void updateWithNamedParameters(){
286266
Assert.assertEquals("f", oDoc.field("gender"));
287267
}
288268

289-
290-
291269
public void updateIncrement() {
292-
293270

294271
List<ODocument> result1 = database.command(new OCommandSQL("select salary from Account where salary is defined")).execute();
295272
Assert.assertFalse(result1.isEmpty());
@@ -321,11 +298,10 @@ public void updateIncrement() {
321298
float salary3 = (Float) result3.get(i).field("salary");
322299
Assert.assertEquals(salary3, salary1);
323300
}
324-
301+
325302
}
326303

327304
public void updateSetMultipleFields() {
328-
329305

330306
List<ODocument> result1 = database.command(new OCommandSQL("select salary from Account where salary is defined")).execute();
331307
Assert.assertFalse(result1.isEmpty());
@@ -345,11 +321,9 @@ public void updateSetMultipleFields() {
345321
Assert.assertEquals(result2.get(i).field("checkpoint"), true);
346322
}
347323

348-
349324
}
350325

351326
public void updateAddMultipleFields() {
352-
353327

354328
updatedRecords = (Integer) database.command(new OCommandSQL("update Account add myCollection = 1, myCollection = 2 limit 1"))
355329
.execute();
@@ -362,7 +336,6 @@ public void updateAddMultipleFields() {
362336

363337
Assert.assertTrue(myCollection.containsAll(Arrays.asList(new Integer[] { 1, 2 })));
364338

365-
366339
}
367340

368341
private void checkUpdatedDoc(ODatabaseDocument database, String expectedName, String expectedCity, String expectedGender) {

0 commit comments

Comments
 (0)