|
8
|
1 |
/*
|
|
|
2 |
* Copyright 2011 Tomas Zeman <tzeman@volny.cz>
|
|
|
3 |
*
|
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
|
6 |
* You may obtain a copy of the License at
|
|
|
7 |
*
|
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
9 |
*
|
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13 |
* See the License for the specific language governing permissions and
|
|
|
14 |
* limitations under the License.
|
|
|
15 |
*/
|
|
|
16 |
package fis.crm.model
|
|
|
17 |
|
|
|
18 |
import fis.base.model._
|
|
|
19 |
import net.liftweb.common._
|
|
|
20 |
import net.liftweb.util._
|
|
|
21 |
import net.liftweb.util.Helpers._
|
|
|
22 |
import org.scalatest._
|
|
|
23 |
|
|
|
24 |
class ContactSpec extends AbstractTest {
|
|
|
25 |
import CrmSchema._
|
|
|
26 |
|
|
|
27 |
override def beforeAll() {
|
|
|
28 |
super.beforeAll
|
|
|
29 |
doInDB { schema.dropAndCreate }
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
"EntityContact" should "create" in { doInDB {
|
|
|
33 |
val c1 = Contact.createRecord.name("c1")
|
|
|
34 |
contacts.insert(c1)
|
|
|
35 |
val t1 = CodeListItem.createRecord.name("t1")
|
|
|
36 |
codeListItems.insert(t1)
|
|
|
37 |
val c2 = Contact.createRecord.name("c2") // acts here as entity
|
|
|
38 |
contacts.insert(c2)
|
|
|
39 |
entityContacts.insert(EntityContact(c2.id, c1.id, t1.id))
|
|
|
40 |
|
|
|
41 |
val el1 = c1.entities.toList
|
|
|
42 |
el1.size should equal (1)
|
|
|
43 |
el1.head.id should equal (c2.id)
|
|
|
44 |
el1.head.name.get should equal ("c2")
|
|
|
45 |
val al1 = c1.entities.associations.toList
|
|
|
46 |
al1.size should equal (1)
|
|
|
47 |
al1.head.contactType.one should equal (Some(t1))
|
|
|
48 |
}}
|
|
|
49 |
|
|
|
50 |
object schema extends CrmSchema with DropAndCreate
|
|
|
51 |
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
// vim: set ts=2 sw=2 et:
|