Skip to content

Commit e352bd6

Browse files
author
Igor Polevoy
committed
typo
1 parent b8fe3be commit e352bd6

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

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

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public void testFindBySQL(){
393393
}
394394

395395
@Test
396-
public void testFrosen(){
396+
public void testFrozen(){
397397
deleteAndPopulateTables("users", "addresses");
398398
final User u = User.findById(1);
399399
final Address a = new Address();
@@ -483,35 +483,44 @@ 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 shouldGenerateValidUpdateSQL() {
488+
public void shouldGenerateCorrectUpdateSQL() {
489+
490+
// Create the student
489491
deleteAndPopulateTable("students");
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);
500-
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
501507
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);
506-
}
507508

508-
@Test(expected = NoSuchElementException.class)
509+
// Verify that the first name column changed
510+
the(s.get("first_name")).shouldBeEqual("Drew");
511+
System.out.println(updateSQL);
512+
513+
}
514+
515+
@Test(expected=NoSuchElementException.class)
509516
public void shouldGenerateNoSuchElementFromBlankUpdate() {
510517
// Verify that a model with no attributes throws an error
511518
Student s = new Student();
519+
s.saveIt();
512520
s.toUpdate();
513521
}
514522

523+
515524
@Test
516525
public void shouldGenerateValidInsertSQL() {
517526
Student s = new Student();
@@ -522,6 +531,7 @@ public void shouldGenerateValidInsertSQL() {
522531
s.setTimestamp("enrollment_date", enrollmentDate);
523532

524533
String insertSql = s.toInsert();
534+
System.out.println(insertSql);
525535
Object id = Base.execInsert(insertSql, s.getIdName());
526536

527537
s = Student.findById(id);

0 commit comments

Comments
 (0)