1
|
|
package fi.eis.libraries.di; |
2
|
|
|
3
|
|
import java.lang.reflect.Field; |
4
|
|
import java.util.ArrayList; |
5
|
|
import java.util.Collections; |
6
|
|
import java.util.List; |
7
|
|
|
8
|
|
/** |
9
|
|
* Creation Date: 30.11.2014 |
10
|
|
* Creation Time: 22:52 |
11
|
|
* |
12
|
|
* @author eis |
13
|
|
*/ |
14
|
|
public class Context { |
15
|
|
|
16
|
|
protected final SimpleLogger logger = new SimpleLogger(this.getClass()); |
17
|
|
|
18
|
2
1. <init> : removed call to java/util/ArrayList::<init> → KILLED
2. <init> : Removed assignment to member variable modules → KILLED
|
protected final List<Module> modules = new ArrayList<Module>(); |
19
|
|
public Context(Module... modules) { |
20
|
1
1. <init> : removed call to java/util/Collections::addAll → KILLED
|
Collections.addAll(this.modules, modules); |
21
|
|
} |
22
|
|
public <T> T get(Class<T> type) { |
23
|
|
logger.debug("context.get=" + type); |
24
|
|
T object = null; |
25
|
|
for (Module module : modules) { |
26
|
|
|
27
|
9
1. get : removed conditional - replaced equality check with true → SURVIVED
2. get : equal to less than → SURVIVED
3. get : equal to less or equal → SURVIVED
4. get : negated conditional → KILLED
5. get : removed call to fi/eis/libraries/di/Module::has → KILLED
6. get : removed conditional - replaced equality check with false → KILLED
7. get : equal to greater than → KILLED
8. get : equal to greater or equal → KILLED
9. get : equal to not equal → KILLED
|
if (module.has(type)) { |
28
|
|
logger.debug("has type " + type); |
29
|
1
1. get : removed call to fi/eis/libraries/di/Module::get → KILLED
|
object = module.get(type); |
30
|
|
break; |
31
|
|
} |
32
|
|
} |
33
|
4
1. get : removed conditional - replaced equality check with false → SURVIVED
2. get : negated conditional → KILLED
3. get : removed conditional - replaced equality check with true → KILLED
4. get : not equal to equal → KILLED
|
if (object == null) { |
34
|
21
1. get : replaced call to java/lang/String::format with argument → NO_COVERAGE
2. get : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE
3. get : Substituted 2 with 3 → NO_COVERAGE
4. get : Substituted 0 with 1 → NO_COVERAGE
5. get : Substituted 1 with 0 → NO_COVERAGE
6. get : removed call to java/lang/String::format → NO_COVERAGE
7. get : Substituted 2 with 1 → NO_COVERAGE
8. get : Substituted 0 with 1 → NO_COVERAGE
9. get : Substituted 2 with 0 → NO_COVERAGE
10. get : Substituted 1 with 0 → NO_COVERAGE
11. get : Substituted 2 with -1 → NO_COVERAGE
12. get : Substituted 0 with -1 → NO_COVERAGE
13. get : Substituted 1 with -1 → NO_COVERAGE
14. get : Substituted 2 with -2 → NO_COVERAGE
15. get : Substituted 1 with -1 → NO_COVERAGE
16. get : Substituted 2 with 3 → NO_COVERAGE
17. get : Substituted 0 with 1 → NO_COVERAGE
18. get : Substituted 1 with 2 → NO_COVERAGE
19. get : Substituted 2 with 1 → NO_COVERAGE
20. get : Substituted 0 with -1 → NO_COVERAGE
21. get : Substituted 1 with 0 → NO_COVERAGE
|
throw new IllegalArgumentException(String.format("Type %s was not found, looking at modules %s", type, modules)); |
35
|
|
} |
36
|
1
1. get : removed call to fi/eis/libraries/di/Context::resolveProperties → KILLED
|
resolveProperties(object); |
37
|
2
1. get : replaced return value with null for fi/eis/libraries/di/Context::get → KILLED
2. get : mutated return of Object value for fi/eis/libraries/di/Context::get to ( if (x != null) null else throw new RuntimeException ) → KILLED
|
return object; |
38
|
|
} |
39
|
|
|
40
|
|
private <T> void resolveProperties(T object) { |
41
|
|
logger.debug("resolveProperties=" + object); |
42
|
|
logger.debug("class=" + object.getClass()); |
43
|
|
|
44
|
|
// @Injected fields |
45
|
2
1. resolveProperties : removed call to java/lang/Object::getClass → KILLED
2. resolveProperties : removed call to java/lang/Class::getDeclaredFields → KILLED
|
Field[] allFields = object.getClass().getDeclaredFields(); |
46
|
|
|
47
|
15
1. resolveProperties : Negated integer local variable number 5 → SURVIVED
2. resolveProperties : Incremented (a++) integer local variable number 5 → SURVIVED
3. resolveProperties : Decremented (a--) integer local variable number 4 → SURVIVED
4. resolveProperties : Decremented (a--) integer local variable number 5 → TIMED_OUT
5. resolveProperties : Negated integer local variable number 5 → KILLED
6. resolveProperties : Negated integer local variable number 4 → KILLED
7. resolveProperties : Incremented (a++) integer local variable number 5 → KILLED
8. resolveProperties : Incremented (a++) integer local variable number 4 → KILLED
9. resolveProperties : Decremented (a--) integer local variable number 5 → KILLED
10. resolveProperties : Incremented (++a) integer local variable number 5 → KILLED
11. resolveProperties : Incremented (++a) integer local variable number 4 → KILLED
12. resolveProperties : Incremented (++a) integer local variable number 5 → KILLED
13. resolveProperties : Decremented (--a) integer local variable number 5 → KILLED
14. resolveProperties : Decremented (--a) integer local variable number 4 → KILLED
15. resolveProperties : Decremented (--a) integer local variable number 5 → KILLED
|
for (Field field : allFields) { |
48
|
9
1. resolveProperties : removed conditional - replaced equality check with true → SURVIVED
2. resolveProperties : equal to less than → SURVIVED
3. resolveProperties : equal to less or equal → SURVIVED
4. resolveProperties : negated conditional → KILLED
5. resolveProperties : removed call to java/lang/reflect/Field::isAnnotationPresent → KILLED
6. resolveProperties : removed conditional - replaced equality check with false → KILLED
7. resolveProperties : equal to greater than → KILLED
8. resolveProperties : equal to greater or equal → KILLED
9. resolveProperties : equal to not equal → KILLED
|
if(field.isAnnotationPresent(Inject.class)) { |
49
|
|
try { |
50
|
1
1. resolveProperties : removed call to java/lang/reflect/Field::isAccessible → SURVIVED
|
boolean originallyAccessible = field.isAccessible(); |
51
|
7
1. resolveProperties : Substituted 1 with 0 → SURVIVED
2. resolveProperties : removed call to java/lang/reflect/Field::setAccessible → SURVIVED
3. resolveProperties : Substituted 1 with 0 → SURVIVED
4. resolveProperties : Substituted 1 with -1 → SURVIVED
5. resolveProperties : Substituted 1 with -1 → SURVIVED
6. resolveProperties : Substituted 1 with 2 → SURVIVED
7. resolveProperties : Substituted 1 with 0 → SURVIVED
|
field.setAccessible(true); |
52
|
3
1. resolveProperties : removed call to java/lang/reflect/Field::getType → KILLED
2. resolveProperties : removed call to fi/eis/libraries/di/Context::get → KILLED
3. resolveProperties : removed call to java/lang/reflect/Field::set → KILLED
|
field.set(object, get(field.getType())); |
53
|
13
1. resolveProperties : negated conditional → SURVIVED
2. resolveProperties : removed conditional - replaced equality check with false → SURVIVED
3. resolveProperties : removed conditional - replaced equality check with true → SURVIVED
4. resolveProperties : Negated integer local variable number 7 → SURVIVED
5. resolveProperties : not equal to less than → SURVIVED
6. resolveProperties : not equal to less or equal → SURVIVED
7. resolveProperties : not equal to greater than → SURVIVED
8. resolveProperties : not equal to greater or equal → SURVIVED
9. resolveProperties : not equal to equal → SURVIVED
10. resolveProperties : Incremented (a++) integer local variable number 7 → SURVIVED
11. resolveProperties : Decremented (a--) integer local variable number 7 → SURVIVED
12. resolveProperties : Incremented (++a) integer local variable number 7 → SURVIVED
13. resolveProperties : Decremented (--a) integer local variable number 7 → SURVIVED
|
if (!originallyAccessible) { |
54
|
6
1. resolveProperties : Substituted 0 with 1 → SURVIVED
2. resolveProperties : removed call to java/lang/reflect/Field::setAccessible → SURVIVED
3. resolveProperties : Substituted 0 with 1 → SURVIVED
4. resolveProperties : Substituted 0 with -1 → SURVIVED
5. resolveProperties : Substituted 0 with 1 → SURVIVED
6. resolveProperties : Substituted 0 with -1 → SURVIVED
|
field.setAccessible(false); |
55
|
|
} |
56
|
|
} catch (IllegalAccessException e) { |
57
|
1
1. resolveProperties : removed call to java/lang/IllegalStateException::<init> → NO_COVERAGE
|
throw new IllegalStateException(e); |
58
|
|
} |
59
|
|
} |
60
|
|
} |
61
|
|
} |
62
|
|
public void setLogLevel(SimpleLogger.LogLevel level) { |
63
|
|
this.logger.setLogLevel(level); |
64
|
|
} |
65
|
|
} |
| | Mutations |
18 |
|
1.1 Location : <init> Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) removed call to java/util/ArrayList::<init> → KILLED 2.2 Location : <init> Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) Removed assignment to member variable modules → KILLED
|
20 |
|
1.1 Location : <init> Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) removed call to java/util/Collections::addAll → KILLED
|
27 |
|
1.1 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) negated conditional → KILLED 2.2 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) removed call to fi/eis/libraries/di/Module::has → KILLED 3.3 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) removed conditional - replaced equality check with false → KILLED 4.4 Location : get Killed by : none removed conditional - replaced equality check with true → SURVIVED 5.5 Location : get Killed by : none equal to less than → SURVIVED 6.6 Location : get Killed by : none equal to less or equal → SURVIVED 7.7 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) equal to greater than → KILLED 8.8 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) equal to greater or equal → KILLED 9.9 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) equal to not equal → KILLED
|
29 |
|
1.1 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) removed call to fi/eis/libraries/di/Module::get → KILLED
|
33 |
|
1.1 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) negated conditional → KILLED 2.2 Location : get Killed by : none removed conditional - replaced equality check with false → SURVIVED 3.3 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) removed conditional - replaced equality check with true → KILLED 4.4 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) not equal to equal → KILLED
|
34 |
|
1.1 Location : get Killed by : none replaced call to java/lang/String::format with argument → NO_COVERAGE 2.2 Location : get Killed by : none removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE 3.3 Location : get Killed by : none Substituted 2 with 3 → NO_COVERAGE 4.4 Location : get Killed by : none Substituted 0 with 1 → NO_COVERAGE 5.5 Location : get Killed by : none Substituted 1 with 0 → NO_COVERAGE 6.6 Location : get Killed by : none removed call to java/lang/String::format → NO_COVERAGE 7.7 Location : get Killed by : none Substituted 2 with 1 → NO_COVERAGE 8.8 Location : get Killed by : none Substituted 0 with 1 → NO_COVERAGE 9.9 Location : get Killed by : none Substituted 2 with 0 → NO_COVERAGE 10.10 Location : get Killed by : none Substituted 1 with 0 → NO_COVERAGE 11.11 Location : get Killed by : none Substituted 2 with -1 → NO_COVERAGE 12.12 Location : get Killed by : none Substituted 0 with -1 → NO_COVERAGE 13.13 Location : get Killed by : none Substituted 1 with -1 → NO_COVERAGE 14.14 Location : get Killed by : none Substituted 2 with -2 → NO_COVERAGE 15.15 Location : get Killed by : none Substituted 1 with -1 → NO_COVERAGE 16.16 Location : get Killed by : none Substituted 2 with 3 → NO_COVERAGE 17.17 Location : get Killed by : none Substituted 0 with 1 → NO_COVERAGE 18.18 Location : get Killed by : none Substituted 1 with 2 → NO_COVERAGE 19.19 Location : get Killed by : none Substituted 2 with 1 → NO_COVERAGE 20.20 Location : get Killed by : none Substituted 0 with -1 → NO_COVERAGE 21.21 Location : get Killed by : none Substituted 1 with 0 → NO_COVERAGE
|
36 |
|
1.1 Location : get Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) removed call to fi/eis/libraries/di/Context::resolveProperties → KILLED
|
37 |
|
1.1 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) replaced return value with null for fi/eis/libraries/di/Context::get → KILLED 2.2 Location : get Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) mutated return of Object value for fi/eis/libraries/di/Context::get to ( if (x != null) null else throw new RuntimeException ) → KILLED
|
45 |
|
1.1 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) removed call to java/lang/Object::getClass → KILLED 2.2 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) removed call to java/lang/Class::getDeclaredFields → KILLED
|
47 |
|
1.1 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) Negated integer local variable number 5 → KILLED 2.2 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) Negated integer local variable number 4 → KILLED 3.3 Location : resolveProperties Killed by : none Negated integer local variable number 5 → SURVIVED 4.4 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) Incremented (a++) integer local variable number 5 → KILLED 5.5 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) Incremented (a++) integer local variable number 4 → KILLED 6.6 Location : resolveProperties Killed by : none Incremented (a++) integer local variable number 5 → SURVIVED 7.7 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) Decremented (a--) integer local variable number 5 → KILLED 8.8 Location : resolveProperties Killed by : none Decremented (a--) integer local variable number 4 → SURVIVED 9.9 Location : resolveProperties Killed by : none Decremented (a--) integer local variable number 5 → TIMED_OUT 10.10 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) Incremented (++a) integer local variable number 5 → KILLED 11.11 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) Incremented (++a) integer local variable number 4 → KILLED 12.12 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) Incremented (++a) integer local variable number 5 → KILLED 13.13 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) Decremented (--a) integer local variable number 5 → KILLED 14.14 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) Decremented (--a) integer local variable number 4 → KILLED 15.15 Location : resolveProperties Killed by : fi.eis.libraries.di.DIConstructorTest.testDi(fi.eis.libraries.di.DIConstructorTest) Decremented (--a) integer local variable number 5 → KILLED
|
48 |
|
1.1 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) negated conditional → KILLED 2.2 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) removed call to java/lang/reflect/Field::isAnnotationPresent → KILLED 3.3 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) removed conditional - replaced equality check with false → KILLED 4.4 Location : resolveProperties Killed by : none removed conditional - replaced equality check with true → SURVIVED 5.5 Location : resolveProperties Killed by : none equal to less than → SURVIVED 6.6 Location : resolveProperties Killed by : none equal to less or equal → SURVIVED 7.7 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) equal to greater than → KILLED 8.8 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) equal to greater or equal → KILLED 9.9 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) equal to not equal → KILLED
|
50 |
|
1.1 Location : resolveProperties Killed by : none removed call to java/lang/reflect/Field::isAccessible → SURVIVED
|
51 |
|
1.1 Location : resolveProperties Killed by : none Substituted 1 with 0 → SURVIVED 2.2 Location : resolveProperties Killed by : none removed call to java/lang/reflect/Field::setAccessible → SURVIVED 3.3 Location : resolveProperties Killed by : none Substituted 1 with 0 → SURVIVED 4.4 Location : resolveProperties Killed by : none Substituted 1 with -1 → SURVIVED 5.5 Location : resolveProperties Killed by : none Substituted 1 with -1 → SURVIVED 6.6 Location : resolveProperties Killed by : none Substituted 1 with 2 → SURVIVED 7.7 Location : resolveProperties Killed by : none Substituted 1 with 0 → SURVIVED
|
52 |
|
1.1 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) removed call to java/lang/reflect/Field::getType → KILLED 2.2 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) removed call to fi/eis/libraries/di/Context::get → KILLED 3.3 Location : resolveProperties Killed by : fi.eis.libraries.di.DIInheritanceTest.testDi(fi.eis.libraries.di.DIInheritanceTest) removed call to java/lang/reflect/Field::set → KILLED
|
53 |
|
1.1 Location : resolveProperties Killed by : none negated conditional → SURVIVED 2.2 Location : resolveProperties Killed by : none removed conditional - replaced equality check with false → SURVIVED 3.3 Location : resolveProperties Killed by : none removed conditional - replaced equality check with true → SURVIVED 4.4 Location : resolveProperties Killed by : none Negated integer local variable number 7 → SURVIVED 5.5 Location : resolveProperties Killed by : none not equal to less than → SURVIVED 6.6 Location : resolveProperties Killed by : none not equal to less or equal → SURVIVED 7.7 Location : resolveProperties Killed by : none not equal to greater than → SURVIVED 8.8 Location : resolveProperties Killed by : none not equal to greater or equal → SURVIVED 9.9 Location : resolveProperties Killed by : none not equal to equal → SURVIVED 10.10 Location : resolveProperties Killed by : none Incremented (a++) integer local variable number 7 → SURVIVED 11.11 Location : resolveProperties Killed by : none Decremented (a--) integer local variable number 7 → SURVIVED 12.12 Location : resolveProperties Killed by : none Incremented (++a) integer local variable number 7 → SURVIVED 13.13 Location : resolveProperties Killed by : none Decremented (--a) integer local variable number 7 → SURVIVED
|
54 |
|
1.1 Location : resolveProperties Killed by : none Substituted 0 with 1 → SURVIVED 2.2 Location : resolveProperties Killed by : none removed call to java/lang/reflect/Field::setAccessible → SURVIVED 3.3 Location : resolveProperties Killed by : none Substituted 0 with 1 → SURVIVED 4.4 Location : resolveProperties Killed by : none Substituted 0 with -1 → SURVIVED 5.5 Location : resolveProperties Killed by : none Substituted 0 with 1 → SURVIVED 6.6 Location : resolveProperties Killed by : none Substituted 0 with -1 → SURVIVED
|
57 |
|
1.1 Location : resolveProperties Killed by : none removed call to java/lang/IllegalStateException::<init> → NO_COVERAGE
|