Skip to content

Commit e43e0ce

Browse files
committed
Reverted overwritten changes by 'typo e352bd6'
1 parent 7092a34 commit e43e0ce

File tree

1 file changed

+19
-29
lines changed

1 file changed

+19
-29
lines changed

activejdbc/src/test/java/org/javalite/activejdbc/ModelTest.java

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -483,44 +483,35 @@ public void shouldGenerateCorrectInsertSQL() {
483483
insertSQL = s.toInsert(new SimpleFormatter(java.sql.Date.class, "to_date('", "')"));
484484
the(insertSQL).shouldBeEqual("INSERT INTO students (dob, first_name, id, last_name) VALUES (to_date('1965-12-01'), 'Jim', 1, 'Cary')");
485485
}
486-
486+
487487
@Test
488-
public void shouldGenerateCorrectUpdateSQL() {
489-
490-
// Create the student
488+
public void shouldGenerateValidUpdateSQL() {
491489
deleteAndPopulateTable("students");
492-
Student s = new Student();
493-
s.set("first_name", "Jim");
494-
s.set("last_name", "Cary");
495-
s.set("dob", new java.sql.Date(getDate(1965, 12, 1).getTime()));
496-
s.set("id", 1);
497-
s.saveIt();
498-
499-
// find them, and change a column
500-
s = Student.findById(1);
501-
s.set("first_name", "Drew");
502-
s.saveIt();
503-
String updateSQL = s.toUpdate();
504-
Base.exec(updateSQL);
505-
506-
// Find them again
507-
s = Student.findById(1);
490+
Student s = Student.findById(1);
491+
s.set("first_name", "James", "last_name", "Meredith");
492+
java.sql.Date dob = getDate(1933, 6, 25);
493+
java.sql.Timestamp enrollmentDate = getTimestamp(1962, 10, 1, 12, 0, 0, 0);
494+
s.setDate("dob", dob);
495+
s.setTimestamp("enrollment_date", enrollmentDate);
496+
// don't save it!
497+
498+
String updateSql = s.toUpdate();
499+
the(Base.exec(updateSql)).shouldBeEqual(1);
508500

509-
// Verify that the first name column changed
510-
the(s.get("first_name")).shouldBeEqual("Drew");
511-
System.out.println(updateSQL);
512-
501+
s = Student.findById(1);
502+
the(s.get("first_name")).shouldBeEqual("James");
503+
the(s.get("last_name")).shouldBeEqual("Meredith");
504+
the(s.get("dob")).shouldBeEqual(dob);
505+
the(s.get("enrollment_date")).shouldBeEqual(enrollmentDate);
513506
}
514-
515-
@Test(expected=NoSuchElementException.class)
507+
508+
@Test(expected = NoSuchElementException.class)
516509
public void shouldGenerateNoSuchElementFromBlankUpdate() {
517510
// Verify that a model with no attributes throws an error
518511
Student s = new Student();
519-
s.saveIt();
520512
s.toUpdate();
521513
}
522514

523-
524515
@Test
525516
public void shouldGenerateValidInsertSQL() {
526517
Student s = new Student();
@@ -531,7 +522,6 @@ public void shouldGenerateValidInsertSQL() {
531522
s.setTimestamp("enrollment_date", enrollmentDate);
532523

533524
String insertSql = s.toInsert();
534-
System.out.println(insertSql);
535525
Object id = Base.execInsert(insertSql, s.getIdName());
536526

537527
s = Student.findById(id);

0 commit comments

Comments
 (0)