ConfigurationInjectionResolver.java

1
package org.maxur.perfmodel.backend.service;
2
3
import org.glassfish.hk2.api.Injectee;
4
import org.glassfish.hk2.api.InjectionResolver;
5
import org.glassfish.hk2.api.ServiceHandle;
6
import org.slf4j.Logger;
7
import org.slf4j.LoggerFactory;
8
9
import javax.inject.Inject;
10
import javax.inject.Named;
11
import java.lang.reflect.Type;
12
13
import static java.lang.String.format;
14
15
/**
16
 * @author Maxim Yunusov
17
 * @version 1.0
18
 * @since <pre>9/2/2015</pre>
19
 */
20
public class ConfigurationInjectionResolver implements InjectionResolver<Named> {
21
22
    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationInjectionResolver.class);
23
24
    @Inject
25
    private PropertiesService propertiesService;
26
27
    @Override
28
    public Object resolve(Injectee injectee, ServiceHandle<?> root) {
29
        Named annotation = injectee.getParent().getAnnotation(Named.class);
30
        final String name = annotation.value();
31
        final Type type = injectee.getRequiredType();
32 1 1. resolve : negated conditional → NO_COVERAGE
        switch (type.getTypeName()) {
33
            case "java.lang.String": {
34 1 1. resolve : mutated return of Object value for org/maxur/perfmodel/backend/service/ConfigurationInjectionResolver::resolve to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE
                return propertiesService.asString(name);
35
            }
36
            default: {
37
                LOGGER.error("Unsupported property type {}", type.getTypeName());
38
                throw new IllegalStateException(format("Unsupported property type %s", type.getTypeName()));
39
            }
40
        }
41
    }
42
43
    @Override
44 1 1. isConstructorParameterIndicator : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
    public boolean isConstructorParameterIndicator() { return false; }
45
46
    @Override
47 1 1. isMethodParameterIndicator : replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE
    public boolean isMethodParameterIndicator() { return false; }
48
}

Mutations

32

1.1
Location : resolve
Killed by : none
negated conditional → NO_COVERAGE

34

1.1
Location : resolve
Killed by : none
mutated return of Object value for org/maxur/perfmodel/backend/service/ConfigurationInjectionResolver::resolve to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE

44

1.1
Location : isConstructorParameterIndicator
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

47

1.1
Location : isMethodParameterIndicator
Killed by : none
replaced return of integer sized value with (x == 0 ? 1 : 0) → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.1.6