1 | /* | |
2 | * Copyright (c) 2013 Maxim Yunusov | |
3 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | * you may not use this file except in compliance with the License. | |
5 | * You may obtain a copy of the License at | |
6 | * | |
7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, software | |
10 | * distributed under the License is distributed on an "AS IS" BASIS, | |
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | * See the License for the specific language governing permissions and | |
13 | * limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.maxur.perfmodel.backend.rest; | |
17 | ||
18 | import com.fasterxml.jackson.databind.ObjectMapper; | |
19 | import com.fasterxml.jackson.databind.SerializationFeature; | |
20 | import org.maxur.perfmodel.backend.domain.Incident; | |
21 | import org.maxur.perfmodel.backend.domain.Project; | |
22 | ||
23 | import javax.ws.rs.ext.ContextResolver; | |
24 | import javax.xml.bind.JAXBException; | |
25 | import java.util.Arrays; | |
26 | import java.util.HashSet; | |
27 | import java.util.Set; | |
28 | ||
29 | /** | |
30 | * @author Maxim Yunusov | |
31 | * @version 1.0 | |
32 | * @since <pre>11/25/13</pre> | |
33 | */ | |
34 | public class PmcObjectMapperProvider implements ContextResolver<ObjectMapper> { | |
35 | ||
36 | private final ObjectMapper context; | |
37 | private final Set<Class<?>> types; | |
38 | ||
39 | public PmcObjectMapperProvider() throws JAXBException{ | |
40 | final Class<?>[] cTypes = {Project.class, Incident.class}; | |
41 | this.types = new HashSet<>(Arrays.asList(cTypes)); | |
42 | this.context = createDefaultMapper(); | |
43 | } | |
44 | ||
45 | @Override | |
46 | public ObjectMapper getContext(Class<?> objectType) { | |
47 |
2
1. getContext : negated conditional → NO_COVERAGE 2. getContext : mutated return of Object value for org/maxur/perfmodel/backend/rest/PmcObjectMapperProvider::getContext to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return types.contains(objectType) ? context : null; |
48 | } | |
49 | ||
50 | private static ObjectMapper createDefaultMapper() { | |
51 | final ObjectMapper result = new ObjectMapper(); | |
52 | result.configure(SerializationFeature.INDENT_OUTPUT, true); | |
53 |
1
1. createDefaultMapper : mutated return of Object value for org/maxur/perfmodel/backend/rest/PmcObjectMapperProvider::createDefaultMapper to ( if (x != null) null else throw new RuntimeException ) → NO_COVERAGE |
return result; |
54 | } | |
55 | } | |
Mutations | ||
47 |
1.1 2.2 |
|
53 |
1.1 |