Code example for Constructor

Methods: newInstance, setAccessible

0
 
	@Test 
	public void giveMeCoverageForMyPrivateConstructor() throws Exception { 
		// reduces only some noise in coverage report 
		final Constructor<VersionParser> constructor = VersionParser.class.getDeclaredConstructor();
		constructor.setAccessible(true);
		constructor.newInstance();
	} 
 
	@Test 
	public void identifyBadaVersion() { 
 
		final String bada10 = "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S7230E/S723EXXJJ3; U; Bada/1.0; nl-nl) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.0 Mobile WQVGA SMM-MMS/1.2.0 OPN-B";
		Assert.assertEquals("1.0", VersionParser.identifyBadaVersion(bada10).toVersionString());
 
		final String bada12 = "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S8500/S8500JHKC1; U; Bada/1.2; en-us) AppleWebKit/533.1 (KHTML, like Gecko) Dolfin/2.2 Mobile WVGA SMM-MMS/1.2.0 OPN-B";
		Assert.assertEquals("1.2", VersionParser.identifyBadaVersion(bada12).toVersionString());
 
		final String bada20 = "Mozilla/5.0 (SAMSUNG; SAMSUNG-GT-S5380K/S5380KDDKK6; U; Bada/2.0; en-us) AppleWebKit/534.20 (KHTML";
		Assert.assertEquals("2.0", VersionParser.identifyBadaVersion(bada20).toVersionString());
	}