Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MockHelper |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2011 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community 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.osedu.org/licenses/ECL-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 org.kuali.student.enrollment.lpr.mock; | |
17 | ||
18 | import java.util.ArrayList; | |
19 | import org.kuali.student.common.infc.*; | |
20 | ||
21 | import java.util.Date; | |
22 | import java.util.List; | |
23 | import org.kuali.student.common.dto.MetaInfo; | |
24 | import org.kuali.student.common.dto.ValidationResultInfo; | |
25 | import org.kuali.student.common.exceptions.DataValidationErrorException; | |
26 | ||
27 | /** | |
28 | * A helper class for the Mock implementation | |
29 | * @author nwright | |
30 | */ | |
31 | 0 | public class MockHelper { |
32 | ||
33 | /** | |
34 | * Create a new MetaInfo with the create id and time as well as the update | |
35 | * date and time and version ind set | |
36 | * @param context | |
37 | * @return | |
38 | */ | |
39 | public MetaInfo createMeta(ContextInfc context) { | |
40 | 0 | MetaInfo.Builder builder = new MetaInfo.Builder(); |
41 | 0 | Date now = new Date(); |
42 | 0 | builder.createId(context.getPrincipalId()).createTime(now).updateId(context.getPrincipalId()); |
43 | 0 | return builder.updateTime(now).versionInd("1").build(); |
44 | } | |
45 | ||
46 | /** | |
47 | * Updates the MetaInfo with new user id and date stamp | |
48 | * Also increments the verssion indicator | |
49 | * @param orig | |
50 | * @param context | |
51 | * @return new metainfo | |
52 | */ | |
53 | public MetaInfo updateMeta(MetaInfc orig, ContextInfc context) { | |
54 | 0 | Date now = new Date(); |
55 | 0 | int oldVersionInd = Integer.parseInt(orig.getVersionInd()); |
56 | 0 | return new MetaInfo.Builder(orig).updateId(context.getPrincipalId()).updateTime(now).versionInd("" + (oldVersionInd + 1)).build(); |
57 | } | |
58 | } | |
59 |