### Question:
ParsedDefine { public static void parseDefine(final Define d, final ParsedDefine p) throws MojoExecutionException { parseDefineName(d.getDefineName(), p); parseDefineValueType(d.getValueType(), p); parseDefineValue(d.getValue(), p); }  void setDefineName(final String defineNameIn); String getDefineName(); void setValue(final Object object); Object getValue(); void setValueType(final Class<?> valueTypeIn); Class<?> getValueType(); String toString(); static void parseDefine(final Define d, final ParsedDefine p);  }### Answer:
@Test(expected = org.apache.maven.plugin.MojoExecutionException.class) public void defineWithNullDefineNameShouldThrowException() throws NoSuchFieldException, IllegalAccessException, MojoExecutionException { String valueNotImportant = ""; Define d = createNewDefineInstance(null, valueNotImportant, valueNotImportant); ParsedDefine p = new ParsedDefine(); ParsedDefine.parseDefine(d, p); }
@Test public void shouldNotAcceptWhiteSpaceInsideDefineName() throws NoSuchFieldException, IllegalAccessException, MojoExecutionException { String defineName; try { defineName = "x x"; Define d = createNewDefineInstance(defineName, null, null); ParsedDefine p = new ParsedDefine(); ParsedDefine.parseDefine(d, p); fail("define name with space should not be accepted"); } catch (org.apache.maven.plugin.MojoExecutionException e) { assertTrue(e.getMessage().contains("can not contain whitespace")); } try { defineName = "x x"; Define d = createNewDefineInstance(defineName, null, null); ParsedDefine p = new ParsedDefine(); ParsedDefine.parseDefine(d, p); fail("define name with tab should not be accepted"); } catch (org.apache.maven.plugin.MojoExecutionException e) { assertTrue(e.getMessage().contains("can not contain whitespace")); } }
@Test public void shouldNotAcceptEqualSignInsideDefineName() throws NoSuchFieldException, IllegalAccessException, MojoExecutionException { try { String defineName = "="; Define d = createNewDefineInstance(defineName, null, null); ParsedDefine p = new ParsedDefine(); ParsedDefine.parseDefine(d, p); fail("define name with equals sign should not be accepted"); } catch (org.apache.maven.plugin.MojoExecutionException e) { assertTrue(e.getMessage().contains("can not contain equal sign")); } }
@Test(expected = org.apache.maven.plugin.MojoExecutionException.class) public void shouldNotAllowEmptyDefineName() throws NoSuchFieldException, IllegalAccessException, MojoExecutionException { Define d = createNewDefineInstance("", null, null); ParsedDefine p = new ParsedDefine(); ParsedDefine.parseDefine(d, p); }
@Test(expected = org.apache.maven.plugin.MojoExecutionException.class) public void shouldComplainAboutUnsupportedValueType() throws NoSuchFieldException, IllegalAccessException, MojoExecutionException { Define d = createNewDefineInstance("my.define", "", "long"); ParsedDefine p = new ParsedDefine(); ParsedDefine.parseDefine(d, p); }
@Test(expected = java.lang.NumberFormatException.class) public void shouldComplainIfCannotConvertValueToInteger() throws NoSuchFieldException, IllegalAccessException, MojoExecutionException { Define d = createNewDefineInstance("my.define", "NaN", "integer"); ParsedDefine p = new ParsedDefine(); ParsedDefine.parseDefine(d, p); }