Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the incompatible issue on parsing npm version #2490

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,83 +35,83 @@ public class Directories

private static final String TEST = "test";

private Map<String, String> directoriesMap = new HashMap<String, String>();
private Map<String, Object> directoriesMap = new HashMap<String, Object>();

protected Directories()
{
}

public String getLib()
public Object getLib()
{
return directoriesMap.get( LIB );
}

public void setLib( String lib )
public void setLib( Object lib )
{
directoriesMap.put( LIB, lib );
}

public String getBin()
public Object getBin()
{
return directoriesMap.get( BIN );
}

public void setBin( String bin )
public void setBin( Object bin )
{
directoriesMap.put( BIN, bin );
}

public String getMan()
public Object getMan()
{
return directoriesMap.get( MAN );
}

public void setMan( String man )
public void setMan( Object man )
{
directoriesMap.put( MAN, man );
}

public String getDoc()
public Object getDoc()
{
return directoriesMap.get( DOC );
}

public void setDoc( String doc )
public void setDoc( Object doc )
{
directoriesMap.put( DOC, doc );
}

public String getExample()
public Object getExample()
{
return directoriesMap.get( EXAMPLE );
}

public void setExample( String example )
public void setExample( Object example )
{
directoriesMap.put( EXAMPLE, example );
}

public String getTest()
public Object getTest()
{
return directoriesMap.get( TEST );
}

public void setTest( String test )
public void setTest( Object test )
{
directoriesMap.put( TEST, test );
}

public Map<String, String> fetchDirectoriesMap()
public Map<String, Object> fetchDirectoriesMap()
{
return directoriesMap;
}

public String getDirectory( String name )
public Object getDirectory( String name )
{
return directoriesMap.get( name );
}

public void putDirectory( String name, String value )
public void putDirectory( String name, Object value )
{
directoriesMap.put( name, value );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@
import org.commonjava.indy.pkg.npm.model.io.PackageSerializerModule;
import org.junit.Test;

import java.net.URL;
import java.nio.charset.Charset;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;

public class VersionMetadataTest
{
Expand Down Expand Up @@ -76,4 +80,24 @@ public void customDeserializerTest() throws Exception
assertThat( version.getLicenses().get( 0 ).getType(), equalTo( "GPLv2" ) );
assertThat( version.getDist().getTarball(), equalTo( "https://registry.npmjs.org/tmp/-/tmp-0.0.4.tgz" ) );
}

//@Test
public void deserializeVersionMetadataTest() throws Exception
{
// Update this url for the specific package version
String url = "https://repository.engineering.redhat.com/nexus/repository/registry.npmjs.org/eslint-plugin-react/7.37.3";

final IndyObjectMapper mapper = new IndyObjectMapper( true );
mapper.registerModule( new PackageSerializerModule() );
String json = IOUtils.toString( new URL(url), Charset.defaultCharset() );

try
{
mapper.readValue(json, VersionMetadata.class);
}
catch (Exception e)
{
fail("Unexpected exception was thrown:" + e.getMessage());
}
}
}
Loading