| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.qedeq.kernel.bo.service; |
| 17 |
|
|
| 18 |
|
import org.qedeq.base.test.QedeqTestCase; |
| 19 |
|
import org.qedeq.kernel.bo.module.InternalKernelServices; |
| 20 |
|
import org.qedeq.kernel.bo.module.KernelModuleReferenceList; |
| 21 |
|
import org.qedeq.kernel.bo.module.ModuleLabels; |
| 22 |
|
import org.qedeq.kernel.bo.test.DummyInternalKernalServices; |
| 23 |
|
import org.qedeq.kernel.common.DefaultModuleAddress; |
| 24 |
|
import org.qedeq.kernel.common.DefaultSourceFileExceptionList; |
| 25 |
|
import org.qedeq.kernel.common.DependencyState; |
| 26 |
|
import org.qedeq.kernel.common.DummyPlugin; |
| 27 |
|
import org.qedeq.kernel.common.LoadingState; |
| 28 |
|
import org.qedeq.kernel.common.QedeqException; |
| 29 |
|
import org.qedeq.kernel.common.SourceFileException; |
| 30 |
|
import org.qedeq.kernel.dto.module.QedeqVo; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
@link |
| 34 |
|
|
| 35 |
|
@author |
| 36 |
|
|
|
|
|
| 85% |
Uncovered Elements: 22 (147) |
Complexity: 27 |
Complexity Density: 0.19 |
|
| 37 |
|
public class DefaultKernelQedeqBoTest extends QedeqTestCase { |
| 38 |
|
|
| 39 |
|
final InternalKernelServices services = new DummyInternalKernalServices(); |
| 40 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
1
PASS
|
|
| 41 |
1
|
public void testConstructor() throws Exception {... |
| 42 |
1
|
try { |
| 43 |
1
|
new DefaultKernelQedeqBo(null, null); |
| 44 |
0
|
fail("RuntimeException expected"); |
| 45 |
|
} catch (RuntimeException e) { |
| 46 |
|
|
| 47 |
|
} |
| 48 |
1
|
new DefaultKernelQedeqBo(services, new DefaultModuleAddress("qedeq.org/text.xml")); |
| 49 |
|
} |
| 50 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
| 51 |
1
|
public void testHasFailures() throws Exception {... |
| 52 |
1
|
DefaultKernelQedeqBo bo; |
| 53 |
1
|
bo = new DefaultKernelQedeqBo(services, new DefaultModuleAddress("qedeq.org/test.xml")); |
| 54 |
1
|
assertFalse(bo.hasErrors()); |
| 55 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED, |
| 56 |
|
new DefaultSourceFileExceptionList(new SourceFileException(DummyPlugin.getInstance(), |
| 57 |
|
new QedeqException(1, "myError") {}, null, null))); |
| 58 |
1
|
assertTrue(bo.hasErrors()); |
| 59 |
1
|
bo.setLoaded(new QedeqVo(), new ModuleLabels()); |
| 60 |
1
|
assertFalse(bo.hasErrors()); |
| 61 |
1
|
bo = new DefaultKernelQedeqBo(services, new DefaultModuleAddress("qedeq.org/test.xml")); |
| 62 |
1
|
bo.setLoaded(new QedeqVo(), new ModuleLabels()); |
| 63 |
1
|
bo.setDependencyFailureState(DependencyState.STATE_LOADING_REQUIRED_MODULES_FAILED, |
| 64 |
|
new DefaultSourceFileExceptionList(new SourceFileException(DummyPlugin.getInstance(), |
| 65 |
|
new QedeqException(1, "myError") {}, null, null))); |
| 66 |
1
|
assertTrue(bo.hasErrors()); |
| 67 |
1
|
bo.setLoadedRequiredModules(new KernelModuleReferenceList()); |
| 68 |
1
|
assertFalse(bo.hasErrors()); |
| 69 |
1
|
bo.setChecked(new ModuleConstantsExistenceChecker(bo)); |
| 70 |
1
|
assertFalse(bo.hasErrors()); |
| 71 |
|
} |
| 72 |
|
|
|
|
|
| 77.8% |
Uncovered Elements: 8 (36) |
Complexity: 9 |
Complexity Density: 0.25 |
1
PASS
|
|
| 73 |
1
|
public void testSetLoadingFailureState() throws Exception {... |
| 74 |
1
|
DefaultKernelQedeqBo bo; |
| 75 |
1
|
bo = new DefaultKernelQedeqBo(services, new DefaultModuleAddress("qedeq.org/test.xml")); |
| 76 |
1
|
assertFalse(bo.hasErrors()); |
| 77 |
1
|
assertNull(bo.getErrors()); |
| 78 |
1
|
try { |
| 79 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED, |
| 80 |
|
null); |
| 81 |
0
|
fail("NullPointerException expected"); |
| 82 |
|
} catch (NullPointerException e) { |
| 83 |
|
|
| 84 |
|
} |
| 85 |
1
|
final DefaultSourceFileExceptionList defaultSourceFileExceptionList |
| 86 |
|
= new DefaultSourceFileExceptionList(new SourceFileException(DummyPlugin.getInstance(), |
| 87 |
|
new QedeqException(1, "myError") {}, null, null)); |
| 88 |
1
|
try { |
| 89 |
1
|
bo.setLoadingFailureState(null, |
| 90 |
|
defaultSourceFileExceptionList); |
| 91 |
0
|
fail("NullPointerException expected"); |
| 92 |
|
} catch (NullPointerException e) { |
| 93 |
|
|
| 94 |
|
} |
| 95 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED, |
| 96 |
|
defaultSourceFileExceptionList); |
| 97 |
1
|
assertEquals(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED, |
| 98 |
|
bo.getLoadingState()); |
| 99 |
1
|
assertEquals(defaultSourceFileExceptionList, bo.getErrors()); |
| 100 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED, |
| 101 |
|
defaultSourceFileExceptionList); |
| 102 |
1
|
assertEquals(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED, |
| 103 |
|
bo.getLoadingState()); |
| 104 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_WEB_FAILED, |
| 105 |
|
defaultSourceFileExceptionList); |
| 106 |
1
|
assertEquals(LoadingState.STATE_LOADING_FROM_WEB_FAILED, |
| 107 |
|
bo.getLoadingState()); |
| 108 |
1
|
try { |
| 109 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADED, |
| 110 |
|
defaultSourceFileExceptionList); |
| 111 |
0
|
fail("IllegalArgumentException expected"); |
| 112 |
|
} catch (IllegalArgumentException e) { |
| 113 |
|
|
| 114 |
|
} |
| 115 |
1
|
try { |
| 116 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_BUFFER, |
| 117 |
|
defaultSourceFileExceptionList); |
| 118 |
0
|
fail("IllegalArgumentException expected"); |
| 119 |
|
} catch (IllegalArgumentException e) { |
| 120 |
|
|
| 121 |
|
} |
| 122 |
1
|
try { |
| 123 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_WEB, |
| 124 |
|
defaultSourceFileExceptionList); |
| 125 |
0
|
fail("IllegalArgumentException expected"); |
| 126 |
|
} catch (IllegalArgumentException e) { |
| 127 |
|
|
| 128 |
|
} |
| 129 |
1
|
try { |
| 130 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADING_INTO_MEMORY, |
| 131 |
|
defaultSourceFileExceptionList); |
| 132 |
0
|
fail("IllegalArgumentException expected"); |
| 133 |
|
} catch (IllegalArgumentException e) { |
| 134 |
|
|
| 135 |
|
} |
| 136 |
1
|
try { |
| 137 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOCATING_WITHIN_WEB, |
| 138 |
|
defaultSourceFileExceptionList); |
| 139 |
0
|
fail("IllegalArgumentException expected"); |
| 140 |
|
} catch (IllegalArgumentException e) { |
| 141 |
|
|
| 142 |
|
} |
| 143 |
1
|
try { |
| 144 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_UNDEFINED, |
| 145 |
|
defaultSourceFileExceptionList); |
| 146 |
0
|
fail("IllegalArgumentException expected"); |
| 147 |
|
} catch (IllegalArgumentException e) { |
| 148 |
|
|
| 149 |
|
} |
| 150 |
|
} |
| 151 |
|
|
|
|
|
| 85.3% |
Uncovered Elements: 5 (34) |
Complexity: 6 |
Complexity Density: 0.18 |
1
PASS
|
|
| 152 |
1
|
public void testSetLoadingProgressState() throws Exception {... |
| 153 |
1
|
DefaultKernelQedeqBo bo; |
| 154 |
1
|
bo = new DefaultKernelQedeqBo(services, new DefaultModuleAddress("qedeq.org/test.xml")); |
| 155 |
1
|
assertFalse(bo.hasErrors()); |
| 156 |
1
|
assertFalse(bo.isLoaded()); |
| 157 |
1
|
assertEquals(LoadingState.STATE_UNDEFINED, bo.getLoadingState()); |
| 158 |
1
|
try { |
| 159 |
1
|
bo.setLoadingProgressState(null); |
| 160 |
0
|
fail("NullPointerException expected"); |
| 161 |
|
} catch (NullPointerException e) { |
| 162 |
|
|
| 163 |
|
} |
| 164 |
1
|
try { |
| 165 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED); |
| 166 |
0
|
fail("IllegalArgumentException expected"); |
| 167 |
|
} catch (IllegalArgumentException e) { |
| 168 |
|
|
| 169 |
|
} |
| 170 |
1
|
try { |
| 171 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_WEB_FAILED); |
| 172 |
0
|
fail("IllegalArgumentException expected"); |
| 173 |
|
} catch (IllegalArgumentException e) { |
| 174 |
|
|
| 175 |
|
} |
| 176 |
1
|
try { |
| 177 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_LOADING_INTO_MEMORY_FAILED); |
| 178 |
0
|
fail("IllegalArgumentException expected"); |
| 179 |
|
} catch (IllegalArgumentException e) { |
| 180 |
|
|
| 181 |
|
} |
| 182 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_UNDEFINED); |
| 183 |
1
|
assertEquals(LoadingState.STATE_UNDEFINED, bo.getLoadingState()); |
| 184 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_BUFFER); |
| 185 |
1
|
assertEquals(LoadingState.STATE_LOADING_FROM_BUFFER, bo.getLoadingState()); |
| 186 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_WEB); |
| 187 |
1
|
assertEquals(LoadingState.STATE_LOADING_FROM_WEB, bo.getLoadingState()); |
| 188 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_LOADING_FROM_WEB); |
| 189 |
1
|
assertEquals(LoadingState.STATE_LOADING_FROM_WEB, bo.getLoadingState()); |
| 190 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_LOADING_INTO_MEMORY); |
| 191 |
1
|
assertEquals(LoadingState.STATE_LOADING_INTO_MEMORY, bo.getLoadingState()); |
| 192 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_LOCATING_WITHIN_WEB); |
| 193 |
1
|
assertEquals(LoadingState.STATE_LOCATING_WITHIN_WEB, bo.getLoadingState()); |
| 194 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_UNDEFINED); |
| 195 |
1
|
assertEquals(LoadingState.STATE_UNDEFINED, bo.getLoadingState()); |
| 196 |
1
|
try { |
| 197 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_LOADED); |
| 198 |
0
|
fail("IllegalArgumentException expected"); |
| 199 |
|
} catch (IllegalArgumentException e) { |
| 200 |
|
|
| 201 |
|
} |
| 202 |
|
} |
| 203 |
|
|
|
|
|
| 84.9% |
Uncovered Elements: 8 (53) |
Complexity: 9 |
Complexity Density: 0.17 |
1
PASS
|
|
| 204 |
1
|
public void testSetDependencyFailureState() throws Exception {... |
| 205 |
1
|
DefaultKernelQedeqBo bo; |
| 206 |
1
|
bo = new DefaultKernelQedeqBo(services, new DefaultModuleAddress("qedeq.org/test.xml")); |
| 207 |
1
|
assertFalse(bo.hasErrors()); |
| 208 |
1
|
assertNull(bo.getErrors()); |
| 209 |
1
|
bo.setLoaded(new QedeqVo(), new ModuleLabels()); |
| 210 |
1
|
assertTrue(bo.isLoaded()); |
| 211 |
1
|
assertNull(bo.getErrors()); |
| 212 |
1
|
try { |
| 213 |
1
|
bo.setDependencyFailureState(DependencyState.STATE_LOADING_REQUIRED_MODULES_FAILED, |
| 214 |
|
null); |
| 215 |
0
|
fail("NullPointerException expected"); |
| 216 |
|
} catch (NullPointerException e) { |
| 217 |
|
|
| 218 |
|
} |
| 219 |
1
|
final DefaultSourceFileExceptionList defaultSourceFileExceptionList |
| 220 |
|
= new DefaultSourceFileExceptionList(new SourceFileException(DummyPlugin.getInstance(), |
| 221 |
|
new QedeqException(1, "myError") {}, null, null)); |
| 222 |
1
|
try { |
| 223 |
1
|
bo.setLoadingFailureState(null, |
| 224 |
|
defaultSourceFileExceptionList); |
| 225 |
0
|
fail("NullPointerException expected"); |
| 226 |
|
} catch (NullPointerException e) { |
| 227 |
|
|
| 228 |
|
} |
| 229 |
1
|
bo.setLoadingProgressState(LoadingState.STATE_UNDEFINED); |
| 230 |
1
|
assertNull(bo.getErrors()); |
| 231 |
1
|
try { |
| 232 |
1
|
bo.setDependencyFailureState(DependencyState.STATE_LOADING_REQUIRED_MODULES_FAILED, |
| 233 |
|
defaultSourceFileExceptionList); |
| 234 |
0
|
fail("IllegalStateException expected"); |
| 235 |
|
} catch (IllegalStateException e) { |
| 236 |
|
|
| 237 |
|
} |
| 238 |
1
|
bo.setLoadingFailureState(LoadingState.STATE_LOADING_FROM_BUFFER_FAILED, |
| 239 |
|
defaultSourceFileExceptionList); |
| 240 |
1
|
try { |
| 241 |
1
|
bo.setDependencyFailureState(DependencyState.STATE_LOADING_REQUIRED_MODULES_FAILED, |
| 242 |
|
defaultSourceFileExceptionList); |
| 243 |
0
|
fail("IllegalStateException expected"); |
| 244 |
|
} catch (IllegalStateException e) { |
| 245 |
|
|
| 246 |
|
} |
| 247 |
1
|
bo.setLoaded(new QedeqVo(), new ModuleLabels()); |
| 248 |
1
|
assertTrue(bo.isLoaded()); |
| 249 |
1
|
assertNull(bo.getErrors()); |
| 250 |
1
|
bo.setDependencyFailureState(DependencyState.STATE_LOADING_REQUIRED_MODULES_FAILED, |
| 251 |
|
defaultSourceFileExceptionList); |
| 252 |
1
|
assertEquals(DependencyState.STATE_LOADING_REQUIRED_MODULES_FAILED, |
| 253 |
|
bo.getDependencyState()); |
| 254 |
1
|
assertEquals(defaultSourceFileExceptionList, bo.getErrors()); |
| 255 |
1
|
bo.setLoaded(new QedeqVo(), new ModuleLabels()); |
| 256 |
1
|
assertTrue(bo.isLoaded()); |
| 257 |
1
|
assertNull(bo.getErrors()); |
| 258 |
1
|
bo.setDependencyProgressState(DependencyState.STATE_UNDEFINED); |
| 259 |
1
|
try { |
| 260 |
1
|
bo.setDependencyFailureState(DependencyState.STATE_UNDEFINED, |
| 261 |
|
defaultSourceFileExceptionList); |
| 262 |
0
|
fail("IllegalArgumentException expected"); |
| 263 |
|
} catch (IllegalArgumentException e) { |
| 264 |
|
|
| 265 |
|
} |
| 266 |
1
|
assertEquals(DependencyState.STATE_UNDEFINED, bo.getDependencyState()); |
| 267 |
1
|
assertNull(bo.getErrors()); |
| 268 |
1
|
try { |
| 269 |
1
|
bo.setDependencyFailureState(DependencyState.STATE_LOADING_REQUIRED_MODULES, |
| 270 |
|
defaultSourceFileExceptionList); |
| 271 |
0
|
fail("IllegalArgumentException expected"); |
| 272 |
|
} catch (IllegalArgumentException e) { |
| 273 |
|
|
| 274 |
|
} |
| 275 |
1
|
assertEquals(DependencyState.STATE_UNDEFINED, bo.getDependencyState()); |
| 276 |
1
|
assertNull(bo.getErrors()); |
| 277 |
1
|
try { |
| 278 |
1
|
bo.setDependencyFailureState(DependencyState.STATE_LOADED_REQUIRED_MODULES, |
| 279 |
|
defaultSourceFileExceptionList); |
| 280 |
0
|
fail("IllegalArgumentException expected"); |
| 281 |
|
} catch (IllegalArgumentException e) { |
| 282 |
|
|
| 283 |
|
} |
| 284 |
1
|
assertEquals(DependencyState.STATE_UNDEFINED, bo.getDependencyState()); |
| 285 |
1
|
assertNull(bo.getErrors()); |
| 286 |
1
|
try { |
| 287 |
1
|
bo.setDependencyFailureState(DependencyState.STATE_LOADED_REQUIRED_MODULES, |
| 288 |
|
defaultSourceFileExceptionList); |
| 289 |
0
|
fail("IllegalArgumentException expected"); |
| 290 |
|
} catch (IllegalArgumentException e) { |
| 291 |
|
|
| 292 |
|
} |
| 293 |
1
|
assertEquals(DependencyState.STATE_UNDEFINED, bo.getDependencyState()); |
| 294 |
1
|
assertNull(bo.getErrors()); |
| 295 |
|
} |
| 296 |
|
|
| 297 |
|
} |