Skip to content

Commit

Permalink
Quick (& dirty) fix for GAVWizardPage.hasParent() (which broke as a r…
Browse files Browse the repository at this point in the history
…esult of the fix for BZ-1169622).
  • Loading branch information
jrenaat committed Jan 20, 2015
1 parent 736ddeb commit 3a8c706
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Expand Up @@ -89,11 +89,11 @@ public void onChange( String newVersion ) {
} );
}

public void setPom( final POM pom ) {
public void setPom( final POM pom, boolean hasParent ) {
this.pomEditor.setPOM( pom,
false );

if ( hasParent( pom ) ) {
if ( hasParent ) {
pomEditor.disableGroupID( view.InheritedFromAParentPOM() );
pomEditor.disableVersion( view.InheritedFromAParentPOM() );
validateArtifactId( pom.getGav().getArtifactId() );
Expand Down Expand Up @@ -131,10 +131,6 @@ public void callback( final Boolean result ) {
} ).validateVersion( version );
}

private boolean hasParent( POM pom ) {
return pom.getGav() != null && pom.getGav().getGroupId() != null && !pom.getGav().getGroupId().trim().isEmpty();
}

@Override
public String getTitle() {
return ProjectEditorResources.CONSTANTS.NewProjectWizard();
Expand Down
Expand Up @@ -109,9 +109,10 @@ public void setContent( final String projectName ) {
pom.getGav().setGroupId( context.getActiveOrganizationalUnit().getDefaultGroupId() );
pom.getGav().setArtifactId( sanitizeProjectName( projectName ) );
pom.getGav().setVersion( "1.0" );
gavWizardPage.setPom( pom );
gavWizardPage.setPom( pom, false );
}

// TODO refactor this ( e.g. pass in parent GAV instead of Strings ) ?
public void setContent( final String projectName,
final String groupId,
final String version ) {
Expand All @@ -124,7 +125,7 @@ public void setContent( final String projectName,
pom.getGav().setGroupId( groupId );
pom.getGav().setArtifactId( sanitizeProjectName( projectName ) );
pom.getGav().setVersion( version );
gavWizardPage.setPom( pom );
gavWizardPage.setPom( pom, true );
}

//The projectName has been validated as a FileSystem folder name, which may not be consistent with Maven ArtifactID
Expand Down
Expand Up @@ -50,7 +50,7 @@ public void setUp() throws Exception {

@Test
public void testPomsWithParentDataDisableFieldsParentNotSet() throws Exception {
page.setPom( new POM() );
page.setPom( new POM(), false );

verify( pomEditor, never() ).disableGroupID( anyString() );
verify( pomEditor, never() ).disableVersion( anyString() );
Expand All @@ -61,7 +61,7 @@ public void testPomsWithParentDataDisableFieldsParentSet() throws Exception {
when( view.InheritedFromAParentPOM() ).thenReturn( "InheritedFromAParentPOM" );
POM pom = new POM();
pom.getGav().setGroupId( "supergroup" );
page.setPom( pom );
page.setPom( pom, true );

verify( pomEditor ).disableGroupID( "InheritedFromAParentPOM" );
verify( pomEditor ).disableVersion( "InheritedFromAParentPOM" );
Expand Down

0 comments on commit 3a8c706

Please sign in to comment.