Search in sources :

Example 1 with PackageSerializerModule

use of org.commonjava.indy.pkg.npm.model.io.PackageSerializerModule in project indy by Commonjava.

the class PackageMetadataMergerTest method setup.

@Before
public void setup() throws Exception {
    cacheProvider = new FileCacheProvider(temp.newFolder("cache"), new IndyPathGenerator(Collections.singleton(new NPMStoragePathCalculator(new SpecialPathManagerImpl()))), new NoOpFileEventManager(), new TransferDecoratorManager(new NoOpTransferDecorator()), false);
    mapper = new IndyObjectMapper(true);
    mapper.registerModule(new PackageSerializerModule());
}
Also used : FileCacheProvider(org.commonjava.maven.galley.cache.FileCacheProvider) NoOpFileEventManager(org.commonjava.maven.galley.event.NoOpFileEventManager) NPMStoragePathCalculator(org.commonjava.indy.pkg.npm.content.NPMStoragePathCalculator) NoOpTransferDecorator(org.commonjava.maven.galley.io.NoOpTransferDecorator) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) TransferDecoratorManager(org.commonjava.maven.galley.io.TransferDecoratorManager) IndyPathGenerator(org.commonjava.indy.content.IndyPathGenerator) PackageSerializerModule(org.commonjava.indy.pkg.npm.model.io.PackageSerializerModule) SpecialPathManagerImpl(org.commonjava.maven.galley.io.SpecialPathManagerImpl) Before(org.junit.Before)

Example 2 with PackageSerializerModule

use of org.commonjava.indy.pkg.npm.model.io.PackageSerializerModule in project indy by Commonjava.

the class VersionMetadataTest method customDeserializerTest.

@Test
public void customDeserializerTest() throws Exception {
    final IndyObjectMapper mapper = new IndyObjectMapper(true);
    mapper.registerModule(new PackageSerializerModule());
    String json = IOUtils.toString(Thread.currentThread().getContextClassLoader().getResourceAsStream("test-package-tmp.json"));
    final PackageMetadata result = mapper.readValue(json, PackageMetadata.class);
    final VersionMetadata version = result.getVersions().get("0.0.4");
    assertThat(result.getVersions().size(), equalTo(5));
    assertThat(version.getName(), equalTo("tmp"));
    assertThat(version.getVersion(), equalTo("0.0.4"));
    assertThat(version.getRepository().getType(), equalTo("git"));
    assertThat(version.getEngines().get(0).getNode(), equalTo("0.4.10"));
    assertThat(version.getScripts().get("test"), equalTo("vows test/*-test.js"));
    assertThat(version.getLicenses().get(0).getType(), equalTo("GPLv2"));
    assertThat(version.getDist().getTarball(), equalTo("https://registry.npmjs.org/tmp/-/tmp-0.0.4.tgz"));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) PackageSerializerModule(org.commonjava.indy.pkg.npm.model.io.PackageSerializerModule) Test(org.junit.Test)

Aggregations

IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)2 PackageSerializerModule (org.commonjava.indy.pkg.npm.model.io.PackageSerializerModule)2 IndyPathGenerator (org.commonjava.indy.content.IndyPathGenerator)1 NPMStoragePathCalculator (org.commonjava.indy.pkg.npm.content.NPMStoragePathCalculator)1 FileCacheProvider (org.commonjava.maven.galley.cache.FileCacheProvider)1 NoOpFileEventManager (org.commonjava.maven.galley.event.NoOpFileEventManager)1 NoOpTransferDecorator (org.commonjava.maven.galley.io.NoOpTransferDecorator)1 SpecialPathManagerImpl (org.commonjava.maven.galley.io.SpecialPathManagerImpl)1 TransferDecoratorManager (org.commonjava.maven.galley.io.TransferDecoratorManager)1 Before (org.junit.Before)1 Test (org.junit.Test)1