Skip to content

Commit e09342d

Browse files
committed
Adding Save test
1 parent cdaca61 commit e09342d

1 file changed

Lines changed: 110 additions & 0 deletions

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/*
2+
* Copyright 2014 summers.
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 com.devnexus.ting.core.dao;
17+
18+
import com.devnexus.ting.core.model.Event;
19+
import com.devnexus.ting.core.model.registration.EventSignup;
20+
import com.devnexus.ting.core.model.registration.PurchaseGroup;
21+
import com.devnexus.ting.core.model.registration.PurchaseItem;
22+
import java.math.BigDecimal;
23+
import java.util.Date;
24+
import org.apache.commons.lang.time.DateUtils;
25+
import org.junit.Assert;
26+
import org.junit.Test;
27+
import org.springframework.beans.factory.annotation.Autowired;
28+
29+
30+
31+
public class EventSignupDaoTest extends BaseDaoIntegrationTest {
32+
33+
@Autowired EventSignupDao signupDao;
34+
@Autowired EventDao eventDao;
35+
36+
@Test
37+
public void save() {
38+
39+
Event event = new Event(42l, "key", "title", true);
40+
event = eventDao.save(event);
41+
42+
EventSignup es = new EventSignup();
43+
44+
es.setEvent(event);
45+
46+
PurchaseGroup group1 = new PurchaseGroup();
47+
PurchaseGroup group2 = new PurchaseGroup();
48+
49+
group1.setEvent(event);
50+
group2.setEvent(event);
51+
group1.setEventSignup(es);
52+
group2.setEventSignup(es);
53+
54+
55+
group1.setLabel("Test Label 1");
56+
group2.setLabel("Test Label 2");
57+
58+
PurchaseItem item1 = new PurchaseItem();
59+
PurchaseItem item2 = new PurchaseItem();
60+
PurchaseItem item3 = new PurchaseItem();
61+
PurchaseItem item4 = new PurchaseItem();
62+
63+
item1.setOpenDate(new Date());
64+
item2.setOpenDate(new Date());
65+
item3.setOpenDate(new Date());
66+
item4.setOpenDate(new Date());
67+
68+
69+
item1.setCloseDate(DateUtils.addDays(new Date(), 5));
70+
item2.setCloseDate(DateUtils.addDays(new Date(), 5));
71+
item3.setCloseDate(DateUtils.addDays(new Date(), 5));
72+
item4.setCloseDate(DateUtils.addDays(new Date(), 5));
73+
74+
item1.setLabel("Test Item Label 1");
75+
item2.setLabel("Test Item Label 2");
76+
item3.setLabel("Test Item Label 3");
77+
item4.setLabel("Test Item Label 4");
78+
79+
80+
item1.setPrice(new BigDecimal("3.50"));
81+
item2.setPrice(new BigDecimal("4.20"));
82+
item3.setPrice(new BigDecimal("1.80"));
83+
item4.setPrice(new BigDecimal("86753.09"));
84+
85+
item1.setEvent(event);
86+
item1.setPurchaseGroup(group1);
87+
item2.setEvent(event);
88+
item2.setPurchaseGroup(group1);
89+
group1.getItems().add(item1);
90+
group1.getItems().add(item2);
91+
92+
item3.setEvent(event);
93+
item3.setPurchaseGroup(group2);
94+
item4.setEvent(event);
95+
item4.setPurchaseGroup(group2);
96+
group2.getItems().add(item3);
97+
group2.getItems().add(item4);
98+
99+
100+
es.getGroups().add(group1);
101+
es.getGroups().add(group2);
102+
103+
es = signupDao.save(es);
104+
Assert.assertNotNull(es.getId());
105+
es = signupDao.getByEventKey("key");
106+
Assert.assertNotNull(es);
107+
}
108+
109+
110+
}

0 commit comments

Comments
 (0)