### Question:
Generator extends AbstractMojo { protected void validatePackageName(String name, String value) throws MojoExecutionException { if (value == null || value.trim().length() == 0 || !value.matches(PACKAGE_PATTERN)) { throw new MojoExecutionException("EasyDao engine configuration exception: wrong " + name + ". Required field, regExp: " + PACKAGE_PATTERN); } }  void execute();  }### Answer:
@Test(expected = MojoExecutionException.class) public void testValidatePackageName_NULL() throws Exception { System.out.println("testValidatePackageName_NULL"); Generator instance = new Generator(); instance.packageOfJavaModel = null; instance.validatePackageName("packageOfJavaModel", instance.packageOfJavaModel); }
@Test(expected = MojoExecutionException.class) public void testValidatePackageName_WRONG1() throws Exception { System.out.println("testValidatePackageName_WRONG1"); Generator instance = new Generator(); instance.packageOfJavaModel = "..."; instance.validatePackageName("packageOfJavaModel", instance.packageOfJavaModel); }
@Test(expected = MojoExecutionException.class) public void testValidatePackageName_WRONG2() throws Exception { System.out.println("testValidatePackageName_WRONG1"); Generator instance = new Generator(); instance.packageOfJavaModel = " "; instance.validatePackageName("packageOfJavaModel", instance.packageOfJavaModel); }
@Test public void testValidatePackageName_GOOD1() throws Exception { System.out.println("testValidatePackageName_GOOD1"); Generator instance = new Generator(); instance.packageOfJavaModel = "hu.vanio.easydao.demo"; instance.validatePackageName("packageOfJavaModel", instance.packageOfJavaModel); }
@Test public void testValidatePackageName_GOOD2() throws Exception { System.out.println("testValidatePackageName_GOOD2"); Generator instance = new Generator(); instance.packageOfJavaModel = "hu"; instance.validatePackageName("packageOfJavaModel", instance.packageOfJavaModel); }