StringToCharsetConverter.java

1
package fr.sii.ogham.core.convert;
2
3
import java.nio.charset.Charset;
4
import java.nio.charset.UnsupportedCharsetException;
5
6
import fr.sii.ogham.core.exception.convert.ConversionException;
7
8
/**
9
 * Converts a string to a {@link Charset} instance. It uses
10
 * {@link Charset#forName(String)} to instantiate the charset.
11
 * 
12
 * 
13
 * @author Aurélien Baudet
14
 *
15
 */
16
public class StringToCharsetConverter implements SupportingConverter {
17
18
	@SuppressWarnings("unchecked")
19
	@Override
20
	public <T> T convert(Object source, Class<T> targetType) {
21
		String charsetName = (String) source;
22 4 1. convert : negated conditional → NO_COVERAGE
2. convert : negated conditional → NO_COVERAGE
3. convert : negated conditional → KILLED
4. convert : negated conditional → KILLED
		if (charsetName == null || charsetName.isEmpty()) {
23
			return null;
24
		}
25
		try {
26 2 1. convert : replaced return value with null for fr/sii/ogham/core/convert/StringToCharsetConverter::convert → NO_COVERAGE
2. convert : replaced return value with null for fr/sii/ogham/core/convert/StringToCharsetConverter::convert → KILLED
			return (T) Charset.forName(charsetName);
27
		} catch(UnsupportedCharsetException e) {
28
			throw new ConversionException("Failed to convert "+charsetName+" into Charset", e);
29
		}
30
	}
31
32
	@Override
33
	public boolean supports(Class<?> sourceType, Class<?> targetType) {
34 18 1. supports : replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → NO_COVERAGE
2. supports : negated conditional → NO_COVERAGE
3. supports : negated conditional → SURVIVED
4. supports : negated conditional → NO_COVERAGE
5. supports : replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → TIMED_OUT
6. supports : negated conditional → TIMED_OUT
7. supports : negated conditional → TIMED_OUT
8. supports : replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED
9. supports : replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED
10. supports : replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED
11. supports : replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED
12. supports : replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED
13. supports : negated conditional → KILLED
14. supports : negated conditional → KILLED
15. supports : negated conditional → KILLED
16. supports : negated conditional → KILLED
17. supports : negated conditional → KILLED
18. supports : negated conditional → KILLED
		return String.class.isAssignableFrom(sourceType) && Charset.class.isAssignableFrom(targetType);
35
	}
36
37
}

Mutations

22

1.1
Location : convert
Killed by : oghamcore.ut.core.convert.StringToCharsetConverterSpec
negated conditional → KILLED

2.2
Location : convert
Killed by : none
negated conditional → NO_COVERAGE

3.3
Location : convert
Killed by : oghamcore.ut.core.convert.StringToCharsetConverterSpec
negated conditional → KILLED

4.4
Location : convert
Killed by : none
negated conditional → NO_COVERAGE

26

1.1
Location : convert
Killed by : oghamcore.ut.core.convert.StringToCharsetConverterSpec
replaced return value with null for fr/sii/ogham/core/convert/StringToCharsetConverter::convert → KILLED

2.2
Location : convert
Killed by : none
replaced return value with null for fr/sii/ogham/core/convert/StringToCharsetConverter::convert → NO_COVERAGE

34

1.1
Location : supports
Killed by : oghamcloudhopper.it.ConnectionFailureTest.invalidSystemId(oghamcloudhopper.it.ConnectionFailureTest)
replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED

2.2
Location : supports
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED

3.3
Location : supports
Killed by : oghamjavamail.it.builder.OverridePropertiesTest.overrideProperties(oghamjavamail.it.builder.OverridePropertiesTest)
replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED

4.4
Location : supports
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED

5.5
Location : supports
Killed by : oghamcore.ut.core.convert.StringToCharsetConverterSpec
replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → KILLED

6.6
Location : supports
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → NO_COVERAGE

7.7
Location : supports
Killed by : none
replaced boolean return with true for fr/sii/ogham/core/convert/StringToCharsetConverter::supports → TIMED_OUT

8.8
Location : supports
Killed by : none
negated conditional → NO_COVERAGE

9.9
Location : supports
Killed by : oghamcore.ut.core.convert.StringToCharsetConverterSpec
negated conditional → KILLED

10.10
Location : supports
Killed by : none
negated conditional → SURVIVED

11.11
Location : supports
Killed by : none
negated conditional → TIMED_OUT

12.12
Location : supports
Killed by : none
negated conditional → NO_COVERAGE

13.13
Location : supports
Killed by : oghamcore.ut.core.convert.StringToCharsetConverterSpec
negated conditional → KILLED

14.14
Location : supports
Killed by : oghamcloudhopper.it.ConnectionFailureTest.invalidSystemId(oghamcloudhopper.it.ConnectionFailureTest)
negated conditional → KILLED

15.15
Location : supports
Killed by : oghamjavamail.it.builder.OverridePropertiesTest.overrideProperties(oghamjavamail.it.builder.OverridePropertiesTest)
negated conditional → KILLED

16.16
Location : supports
Killed by : oghamsmsglobal.it.SmsglobalServiceProviderConfigurerSpec
negated conditional → KILLED

17.17
Location : supports
Killed by : none
negated conditional → TIMED_OUT

18.18
Location : supports
Killed by : oghamall.it.configuration.EmptyBuilderTest.emailSenderManuallyRegisteredButUnconfiguredTemplateParsersCantHandleMultiTemplateContent(oghamall.it.configuration.EmptyBuilderTest)
negated conditional → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM