JsonMessageBodyWriter.java

1
/*-
2
 * #%L
3
 * io.earcam.utilitarian.web.jaxrs
4
 * %%
5
 * Copyright (C) 2017 earcam
6
 * %%
7
 * SPDX-License-Identifier: (BSD-3-Clause OR EPL-1.0 OR Apache-2.0 OR MIT)
8
 *
9
 * You <b>must</b> choose to accept, in full - any individual or combination of
10
 * the following licenses:
11
 * <ul>
12
 * 	<li><a href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</a></li>
13
 * 	<li><a href="https://www.eclipse.org/legal/epl-v10.html">EPL-1.0</a></li>
14
 * 	<li><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></li>
15
 * 	<li><a href="https://opensource.org/licenses/MIT">MIT</a></li>
16
 * </ul>
17
 * #L%
18
 */
19
package io.earcam.utilitarian.web.jaxrs;
20
21
import static io.earcam.utilitarian.web.jaxrs.JsonMessageBodyReader.JSONB;
22
import static io.earcam.utilitarian.web.jaxrs.JsonMessageBodyReader.isJson;
23
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
24
25
import java.io.OutputStream;
26
import java.lang.annotation.Annotation;
27
import java.lang.reflect.Type;
28
29
import javax.ws.rs.Produces;
30
import javax.ws.rs.core.MediaType;
31
import javax.ws.rs.core.MultivaluedMap;
32
import javax.ws.rs.ext.MessageBodyWriter;
33
import javax.ws.rs.ext.Provider;
34
35
import io.earcam.unexceptional.Exceptional;
36
37
@Produces(APPLICATION_JSON)
38
@Provider
39
public class JsonMessageBodyWriter implements MessageBodyWriter<Object> {
40
41
	@Override
42
	public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
43
	{
44 1 1. isWriteable : replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED
		return isJson(mediaType);
45
	}
46
47
48
	@Override
49
	public long getSize(Object instance, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
50
	{
51 1 1. getSize : replaced return of long value with value + 1 for io/earcam/utilitarian/web/jaxrs/JsonMessageBodyWriter::getSize → KILLED
		return -1;
52
	}
53
54
55
	@Override
56
	public void writeTo(Object instance, Class<?> type,
57
			Type gt, Annotation[] anno, MediaType mt,
58
			MultivaluedMap<String, Object> h, OutputStream entityStream)
59
	{
60 2 1. lambda$writeTo$0 : removed call to javax/json/bind/Jsonb::toJson → KILLED
2. writeTo : removed call to io/earcam/unexceptional/Exceptional::run → KILLED
		Exceptional.run(() -> JSONB.toJson(instance, gt, entityStream));
61
	}
62
}

Mutations

44

1.1
Location : isWriteable
Killed by : io.earcam.utilitarian.web.jaxrs.JaxRsTest.getAgain
replaced return of integer sized value with (x == 0 ? 1 : 0) → KILLED

51

1.1
Location : getSize
Killed by : io.earcam.utilitarian.web.jaxrs.JsonMessageBodyWriterTest.getSizeIsMinusOne()
replaced return of long value with value + 1 for io/earcam/utilitarian/web/jaxrs/JsonMessageBodyWriter::getSize → KILLED

60

1.1
Location : lambda$writeTo$0
Killed by : io.earcam.utilitarian.web.jaxrs.JsonMessageBodyWriterTest.symmetric()
removed call to javax/json/bind/Jsonb::toJson → KILLED

2.2
Location : writeTo
Killed by : io.earcam.utilitarian.web.jaxrs.JsonMessageBodyWriterTest.symmetric()
removed call to io/earcam/unexceptional/Exceptional::run → KILLED

Active mutators

Tests examined


Report generated by PIT 1.4.3