|
| 1 | +package org.openmrs.module; |
| 2 | + |
| 3 | +import java.util.Date; |
| 4 | +import java.util.HashMap; |
| 5 | +import java.util.Map; |
| 6 | + |
| 7 | +public class ModuleTestData { Has conversations. Original line has conversations. |
| 8 | + |
| 9 | + private Map<String, Integer> willRefreshContextCallCount = new HashMap<String, Integer>(); |
| 10 | + |
| 11 | + private Map<String, Integer> contextRefreshedCallCount = new HashMap<String, Integer>(); |
| 12 | + |
| 13 | + private Map<String, Integer> willStartCallCount = new HashMap<String, Integer>(); |
| 14 | + |
| 15 | + private Map<String, Integer> startedCallCount = new HashMap<String, Integer>(); |
| 16 | + |
| 17 | + private Map<String, Integer> willStopCallCount = new HashMap<String, Integer>(); |
| 18 | + |
| 19 | + private Map<String, Integer> stoppedCallCount = new HashMap<String, Integer>(); |
| 20 | + |
| 21 | + private Map<String, Long> willRefreshContextCallTime = new HashMap<String, Long>(); |
| 22 | + |
| 23 | + private Map<String, Long> contextRefreshedCallTime = new HashMap<String, Long>(); Has conversations. Original line has conversations. |
| 24 | + |
| 25 | + private Map<String, Long> willStartCallTime = new HashMap<String, Long>(); |
| 26 | + |
| 27 | + private Map<String, Long> startedCallTime = new HashMap<String, Long>(); |
| 28 | + |
| 29 | + private Map<String, Long> willStopCallTime = new HashMap<String, Long>(); |
| 30 | + |
| 31 | + private Map<String, Long> stoppedCallTime = new HashMap<String, Long>(); |
| 32 | + |
| 33 | + private ModuleTestData() { |
| 34 | + |
| 35 | + } |
| 36 | + |
| 37 | + private static class ModuleTestDataHolder { |
| 38 | + |
| 39 | + private static ModuleTestData INSTANCE = null; |
| 40 | + } |
| 41 | + |
| 42 | + public static ModuleTestData getInstance() { |
| 43 | + if (ModuleTestDataHolder.INSTANCE == null) |
| 44 | + ModuleTestDataHolder.INSTANCE = new ModuleTestData(); |
| 45 | + |
| 46 | + return ModuleTestDataHolder.INSTANCE; |
| 47 | + } |
| 48 | + |
| 49 | + public void init(String moduleId) { |
| 50 | + willRefreshContextCallCount.put(moduleId, 0); |
| 51 | + contextRefreshedCallCount.put(moduleId, 0); |
| 52 | + willStartCallCount.put(moduleId, 0); |
| 53 | + startedCallCount.put(moduleId, 0); |
| 54 | + willStopCallCount.put(moduleId, 0); |
| 55 | + stoppedCallCount.put(moduleId, 0); |
| 56 | + |
| 57 | + willRefreshContextCallTime.put(moduleId, 0l); |
| 58 | + contextRefreshedCallTime.put(moduleId, 0l); |
| 59 | + willStartCallTime.put(moduleId, 0l); |
| 60 | + startedCallTime.put(moduleId, 0l); |
| 61 | + willStopCallTime.put(moduleId, 0l); |
| 62 | + stoppedCallTime.put(moduleId, 0l); |
| 63 | + } |
| 64 | + |
| 65 | + public Integer getWillRefreshContextCallCount(String moduleId) { |
| 66 | + Integer count = willRefreshContextCallCount.get(moduleId); |
| 67 | + if (count == null) { |
| 68 | + count = 0; |
| 69 | + } |
| 70 | + return count; |
| 71 | + } |
| 72 | + |
| 73 | + public Integer getContextRefreshedCallCount(String moduleId) { |
| 74 | + Integer count = contextRefreshedCallCount.get(moduleId); |
| 75 | + if (count == null) { |
| 76 | + count = 0; |
| 77 | + } |
| 78 | + return count; |
| 79 | + } |
| 80 | + |
| 81 | + public Integer getWillStartCallCount(String moduleId) { |
| 82 | + Integer count = willStartCallCount.get(moduleId); |
| 83 | + if (count == null) { |
| 84 | + count = 0; |
| 85 | + } |
| 86 | + return count; |
| 87 | + } |
| 88 | + |
| 89 | + public Integer getStartedCallCount(String moduleId) { |
| 90 | + Integer count = startedCallCount.get(moduleId); |
| 91 | + if (count == null) { |
| 92 | + count = 0; |
| 93 | + } |
| 94 | + return count; |
| 95 | + } |
| 96 | + |
| 97 | + public Integer getWillStopCallCount(String moduleId) { |
| 98 | + Integer count = willStopCallCount.get(moduleId); |
| 99 | + if (count == null) { |
| 100 | + count = 0; |
| 101 | + } |
| 102 | + return count; |
| 103 | + } |
| 104 | + |
| 105 | + public Integer getStoppedCallCount(String moduleId) { |
| 106 | + Integer count = stoppedCallCount.get(moduleId); |
| 107 | + if (count == null) { |
| 108 | + count = 0; |
| 109 | + } |
| 110 | + return count; |
| 111 | + } |
| 112 | + |
| 113 | + public void willRefreshContext(String moduleId) { |
| 114 | + willRefreshContextCallTime.put(moduleId, new Date().getTime()); |
| 115 | + |
| 116 | + Integer count = willRefreshContextCallCount.get(moduleId); |
| 117 | + if (count == null) { |
| 118 | + count = 0; |
| 119 | + } |
| 120 | + willRefreshContextCallCount.put(moduleId, count + 1); |
| 121 | + } |
| 122 | + |
| 123 | + public void contextRefreshed(String moduleId) { |
| 124 | + contextRefreshedCallTime.put(moduleId, new Date().getTime()); |
| 125 | + |
| 126 | + Integer count = contextRefreshedCallCount.get(moduleId); |
| 127 | + if (count == null) { |
| 128 | + count = 0; |
| 129 | + } |
| 130 | + contextRefreshedCallCount.put(moduleId, count + 1); |
| 131 | + } |
| 132 | + |
| 133 | + public void willStart(String moduleId) { |
| 134 | + willStartCallTime.put(moduleId, new Date().getTime()); |
| 135 | + |
| 136 | + Integer count = willStartCallCount.get(moduleId); |
| 137 | + if (count == null) { |
| 138 | + count = 0; |
| 139 | + } |
| 140 | + willStartCallCount.put(moduleId, count + 1); |
| 141 | + } |
| 142 | + |
| 143 | + public void started(String moduleId) { |
| 144 | + startedCallTime.put(moduleId, new Date().getTime()); |
| 145 | + |
| 146 | + Integer count = startedCallCount.get(moduleId); |
| 147 | + if (count == null) { |
| 148 | + count = 0; |
| 149 | + } |
| 150 | + startedCallCount.put(moduleId, count + 1); |
| 151 | + } |
| 152 | + |
| 153 | + public void willStop(String moduleId) { |
| 154 | + willStopCallTime.put(moduleId, new Date().getTime()); |
| 155 | + |
| 156 | + Integer count = willStopCallCount.get(moduleId); |
| 157 | + if (count == null) { |
| 158 | + count = 0; |
| 159 | + } |
| 160 | + willStopCallCount.put(moduleId, count + 1); |
| 161 | + } |
| 162 | + |
| 163 | + public void stopped(String moduleId) { |
| 164 | + stoppedCallTime.put(moduleId, new Date().getTime()); |
| 165 | + |
| 166 | + Integer count = stoppedCallCount.get(moduleId); |
| 167 | + if (count == null) { |
| 168 | + count = 0; |
| 169 | + } |
| 170 | + stoppedCallCount.put(moduleId, count + 1); |
| 171 | + } |
| 172 | + |
| 173 | + public Long getWillRefreshContextCallTime(String moduleId) { |
| 174 | + return willRefreshContextCallTime.get(moduleId); |
| 175 | + } |
| 176 | + |
| 177 | + public Long getContextRefreshedCallTime(String moduleId) { |
| 178 | + return contextRefreshedCallTime.get(moduleId); |
| 179 | + } |
| 180 | + |
| 181 | + public Long getWillStartCallTime(String moduleId) { |
| 182 | + return willStartCallTime.get(moduleId); |
| 183 | + } |
| 184 | + |
| 185 | + public Long getStartedCallTime(String moduleId) { |
| 186 | + return startedCallTime.get(moduleId); |
| 187 | + } |
| 188 | + |
| 189 | + public Long getWillStopCallTime(String moduleId) { |
| 190 | + return willStopCallTime.get(moduleId); |
| 191 | + } |
| 192 | + |
| 193 | + public Long getStoppedCallTime(String moduleId) { |
| 194 | + return stoppedCallTime.get(moduleId); |
| 195 | + } |
| 196 | +} |