1 /** 2 * Copyright 2010 The Kuali Foundation Licensed under the 3 * Educational Community License, Version 2.0 (the "License"); you may 4 * not use this file except in compliance with the License. You may 5 * obtain a copy of the License at 6 * 7 * http://www.osedu.org/licenses/ECL-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, 10 * software distributed under the License is distributed on an "AS IS" 11 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 * or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package org.kuali.student.r1.core.atp; 17 18 import static org.junit.Assert.assertEquals; 19 import static org.junit.Assert.assertTrue; 20 import static org.junit.Assert.fail; 21 22 import org.junit.Ignore; 23 import org.kuali.student.common.test.spring.AbstractServiceTest; 24 import org.kuali.student.common.test.spring.Dao; 25 import org.kuali.student.common.test.spring.Daos; 26 import org.kuali.student.common.test.spring.PersistenceFileLocation; 27 28 @Ignore 29 @Daos( { @Dao(value = "org.kuali.student.r1.core.atp.dao.impl.AtpDaoImpl", testDataFile = "classpath:atp-test-beans.xml") }) 30 @PersistenceFileLocation("classpath:META-INF/atp-persistence.xml") 31 public class TestAtpService extends AbstractServiceTest { 32 // final Logger LOG = Logger.getLogger(TestAtpService.class); 33 // 34 // @Client(value = "org.kuali.student.r1.core.atp.service.impl.AtpServiceImpl", additionalContextFile="classpath:atp-additional-context.xml") 35 // public AtpService atpService; 36 // @Client(value = "org.kuali.student.r2.common.type.service.TypeServiceImpl", additionalContextFile="classpath:atp-additional-context.xml") 37 // public TypeService typeService; 38 // 39 // public static final String atpType_fallSemester = "atp.atpType.fallSemester"; 40 // public static final String milestoneType_lastDateToDrop = "atp.milestoneType.lastDateToDrop"; 41 // public static final String dateRangeType_finals = "atp.dateRangeType.finals"; 42 // public static final String atpAttribute_notes = "atp.attribute.notes"; 43 // public static final String dateRangeAttribute_notes = "atp.dateRangeAttribute.notes"; 44 // public static final String milestoneAttribute_notes = "atp.milestoneAttribute.notes"; 45 // public static final String atp_fall2008Semester = "atp.fall2008Semester"; 46 // public static final String milestone_lastDateToDropFall2008 = "atp.milestone.lastDateToDropFall2008"; 47 // public static final String dateRange_finalsFall2008 = "atp.dateRange.finalsFall2008"; 48 // 49 // public static final String atp_2009FallSemester = "atp.2009FallSemester"; 50 // 51 // @Test 52 // public void TestFinds() throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, ParseException{ 53 // 54 // Calendar cal = Calendar.getInstance(); 55 // cal.set(2009, 9, 1); 56 // 57 // Calendar startCal = Calendar.getInstance(); 58 // startCal.set(2008, 1, 1); 59 // 60 // Calendar endCal = Calendar.getInstance(); 61 // endCal.set(2010, 1, 1); 62 // 63 // SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd"); 64 // 65 // List<TypeInfo> atpTypes = atpService.getAtpTypes(); 66 // assertEquals(2,atpTypes.size()); 67 // 68 // List<AtpInfo> atpsByAtpType = atpService.getAtpsByAtpType(atpType_fallSemester); 69 // assertEquals(1,atpsByAtpType.size()); 70 // assertEquals(atp_2009FallSemester,atpsByAtpType.get(0).getId()); 71 // 72 // List<AtpInfo> atpsByDate = atpService.getAtpsByDate(cal.getTime()); 73 // assertEquals(1,atpsByDate.size()); 74 // assertEquals(atp_2009FallSemester,atpsByDate.get(0).getId()); 75 // 76 // List<AtpInfo> atpsByDates = atpService.getAtpsByDates(startCal.getTime(), endCal.getTime()); 77 // assertEquals(2,atpsByDates.size()); 78 // 79 // List<DateRangeInfo> dateRangesByAtp = atpService.getDateRangesByAtp(atp_2009FallSemester); 80 // assertEquals(1,dateRangesByAtp.size()); 81 // 82 // List<DateRangeInfo> dateRangesByDate = atpService.getDateRangesByDate(df.parse("20091205")); 83 // assertEquals(1,dateRangesByDate.size()); 84 // 85 // List<DateRangeTypeInfo> dateRangeTypesForAtpType = atpService.getDateRangeTypesForAtpType(atpType_fallSemester); 86 // assertEquals(1,dateRangeTypesForAtpType.size()); 87 // 88 // List<MilestoneInfo> milestonesByAtp = atpService.getMilestonesByAtp(atp_2009FallSemester); 89 // assertEquals(1,milestonesByAtp.size()); 90 // 91 // List<MilestoneInfo> milestonesByDates = atpService.getMilestonesByDates(startCal.getTime(), endCal.getTime()); 92 // assertEquals(1,milestonesByDates.size()); 93 // 94 // List<MilestoneInfo> milestonesByDatesAndType = atpService.getMilestonesByDatesAndType(milestoneType_lastDateToDrop, startCal.getTime(), endCal.getTime()); 95 // assertEquals(1,milestonesByDatesAndType.size()); 96 // 97 // List<MilestoneTypeInfo> milestoneTypesForAtpType = atpService.getMilestoneTypesForAtpType(atpType_fallSemester); 98 // assertEquals(1,milestoneTypesForAtpType.size()); 99 // } 100 // 101 // @Test 102 // public void TestCreateUpdateDelete(){ 103 // //Make an ATP 104 // AtpInfo atpInfo = new AtpInfo(); 105 // atpInfo.setDesc(new RichTextInfo()); 106 // atpInfo.getDesc().setFormatted("Atp for fall 2008 semester"); 107 // atpInfo.getDesc().setPlain("Atp for fall 2008 semester"); 108 // atpInfo.setName("Fall 2008 Semester"); 109 // atpInfo.setStartDate(new Date()); 110 // atpInfo.setEndDate(new Date()); 111 // 112 // Date stDate = atpInfo.getStartDate(); 113 // Date enDate = atpInfo.getEndDate(); 114 // 115 // atpInfo.setState("new"); 116 // 117 // atpInfo.getAttributes().put(atpAttribute_notes, "Notes for the Fall 2008 Semester"); 118 // 119 // AtpInfo createdAtp=null; 120 // try { 121 // createdAtp = atpService.createAtp(atpType_fallSemester, atp_fall2008Semester, atpInfo); 122 // } catch (Exception e) { 123 // LOG.error(e); 124 // fail(); 125 // } 126 // 127 // assertTrue(stDate.equals(createdAtp.getStartDate())); 128 // assertTrue(enDate.equals(createdAtp.getEndDate())); 129 // 130 // //Make a DateRange 131 // DateRangeInfo dateRangeInfo=new DateRangeInfo(); 132 // dateRangeInfo.setDesc(new RichTextInfo()); 133 // dateRangeInfo.getDesc().setFormatted("Date Range for fall 2008 semester finals"); 134 // dateRangeInfo.setName("Finals Fall 2008 Semester"); 135 // dateRangeInfo.setStartDate(new Date()); 136 // dateRangeInfo.setEndDate(new Date()); 137 // dateRangeInfo.setState("new"); 138 // dateRangeInfo.setAtpId(atp_fall2008Semester); 139 // dateRangeInfo.setType(dateRangeType_finals); 140 // 141 // dateRangeInfo.getAttributes().put(dateRangeAttribute_notes, "Notes for the Finals date range Fall 2008 Semester"); 142 // 143 // DateRangeInfo createdDateRange=null; 144 // try { 145 // createdDateRange = atpService.addDateRange(atp_fall2008Semester, dateRange_finalsFall2008, dateRangeInfo); 146 // } catch (Exception e) { 147 // LOG.error(e); 148 // fail(); 149 // } 150 // 151 // //Make a Milestone 152 // MilestoneInfo milestoneInfo=new MilestoneInfo(); 153 // milestoneInfo.setDesc(new RichTextInfo()); 154 // milestoneInfo.getDesc().setFormatted("Milestone for fall 2008 semester last day to drop"); 155 // milestoneInfo.setName("Last Day to Drop Fall 2008 Semester"); 156 // milestoneInfo.setMilestoneDate(new Date()); 157 // milestoneInfo.setState("new"); 158 // milestoneInfo.setAtpId(atp_fall2008Semester); 159 // milestoneInfo.setType(milestoneType_lastDateToDrop); 160 // 161 // milestoneInfo.getAttributes().put(milestoneAttribute_notes, "Notes for the Last Day to Drop Fall 2008 Semester"); 162 // 163 // MilestoneInfo createdMilestone=null; 164 // try { 165 // createdMilestone = atpService.addMilestone(atp_fall2008Semester, milestone_lastDateToDropFall2008, milestoneInfo); 166 // } catch (Exception e) { 167 // LOG.error(e); 168 // fail(); 169 // } 170 // 171 // //Do some updates 172 // 173 // //Update Atp 174 // createdAtp.getDesc().setFormatted("Updated Atp for the Fall 2008 Semester"); 175 // try { 176 // assertEquals("0",createdAtp.getMetaInfo().getVersionInd()); 177 // AtpInfo updatedAtp = atpService.updateAtp(atp_fall2008Semester, createdAtp); 178 // assertEquals("1",updatedAtp.getMetaInfo().getVersionInd()); 179 // assertEquals("Updated Atp for the Fall 2008 Semester", updatedAtp.getDesc().getFormatted()); 180 // } catch (Exception e) { 181 // LOG.error(e); 182 // fail(); 183 // } 184 // 185 // //now try to update again with the same version 186 // try { 187 // atpService.updateAtp(atp_fall2008Semester, createdAtp); 188 // fail("AtpService.updateAtp() should have thrown VersionMismatchException"); 189 // } catch (VersionMismatchException vme) { 190 // // what we expect 191 // } catch (Exception e) { 192 // LOG.error(e); 193 // fail(); 194 // } 195 // 196 // //Update Date Range 197 // createdDateRange.getDesc().setFormatted("Updated DateRange for the Finals date range Fall 2008 Semester"); 198 // try { 199 // assertEquals("0",createdDateRange.getMetaInfo().getVersionInd()); 200 // DateRangeInfo updatedDateRange = atpService.updateDateRange(dateRange_finalsFall2008, createdDateRange); 201 // assertEquals("1",updatedDateRange.getMetaInfo().getVersionInd()); 202 // assertEquals("Updated DateRange for the Finals date range Fall 2008 Semester", updatedDateRange.getDesc().getFormatted()); 203 // } catch (Exception e) { 204 // LOG.error(e); 205 // fail(); 206 // } 207 // 208 // //Updating with the old version again should fail 209 // try { 210 // atpService.updateDateRange(dateRange_finalsFall2008, createdDateRange); 211 // fail("AtpService.updateDateRange() should have thrown VersionMismatchException"); 212 // } catch (VersionMismatchException vme) { 213 // // what we expect 214 // } catch (Exception e) { 215 // LOG.error(e); 216 // fail(); 217 // } 218 // 219 // //Update Milestone 220 // createdMilestone.getDesc().setFormatted("Updated Milestone for fall 2008 semester last day to drop"); 221 // try { 222 // assertEquals("0",createdMilestone.getMetaInfo().getVersionInd()); 223 // MilestoneInfo updatedMilestone = atpService.updateMilestone(milestone_lastDateToDropFall2008, createdMilestone); 224 // assertEquals("1",updatedMilestone.getMetaInfo().getVersionInd()); 225 // assertEquals("Updated Milestone for fall 2008 semester last day to drop", updatedMilestone.getDesc().getFormatted()); 226 // } catch (Exception e) { 227 // LOG.error(e); 228 // } 229 // 230 // //Try to update again should fail 231 // try { 232 // atpService.updateMilestone(milestone_lastDateToDropFall2008, createdMilestone); 233 // fail("AtpService.updateDateRange() should have thrown VersionMismatchException"); 234 // } catch (VersionMismatchException vme) { 235 // // what we expect 236 // } catch (Exception e) { 237 // LOG.error(e); 238 // fail(); 239 // } 240 // 241 // //Do some deletes that should cascade 242 // try { 243 // atpService.deleteAtp(atp_fall2008Semester); 244 // } catch (Exception e) { 245 // LOG.error(e); 246 // fail(); 247 // } 248 // } 249 }