Search in sources :

Example 51 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class AbstractIndyFunctionalTest method createIndyClient.

protected Indy createIndyClient() throws IndyClientException {
    SiteConfig config = new SiteConfigBuilder("indy", fixture.getUrl()).withRequestTimeoutSeconds(60).build();
    Collection<IndyClientModule> modules = getAdditionalClientModules();
    return new Indy(config, new MemoryPasswordManager(), new IndyObjectMapper(getAdditionalMapperModules()), modules.toArray(new IndyClientModule[modules.size()]));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) SiteConfigBuilder(org.commonjava.util.jhttpc.model.SiteConfigBuilder) Indy(org.commonjava.indy.client.core.Indy) SiteConfig(org.commonjava.util.jhttpc.model.SiteConfig) MemoryPasswordManager(org.commonjava.util.jhttpc.auth.MemoryPasswordManager) IndyClientModule(org.commonjava.indy.client.core.IndyClientModule)

Example 52 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class RuleDTOTest method jsonRoundTrip.

@Test
public void jsonRoundTrip() throws IOException {
    try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("test-autoprox-rule.groovy")) {
        String spec = IOUtils.toString(stream);
        RuleDTO in = new RuleDTO("test", spec);
        IndyObjectMapper mapper = new IndyObjectMapper(true);
        String json = mapper.writeValueAsString(in);
        RuleDTO out = mapper.readValue(json, RuleDTO.class);
        assertThat(out, notNullValue());
        assertThat(out.getName(), equalTo(in.getName()));
        assertThat(out.getSpec(), equalTo(in.getSpec()));
        assertThat(out, equalTo(in));
    }
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 53 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class DownloadDiagBundleTest method createIndyClient.

protected Indy createIndyClient() throws IndyClientException {
    SiteConfig config = new SiteConfigBuilder("indy", fixture.getUrl()).withRequestTimeoutSeconds(120).build();
    Collection<IndyClientModule> modules = getAdditionalClientModules();
    return new Indy(config, new MemoryPasswordManager(), new IndyObjectMapper(getAdditionalMapperModules()), modules.toArray(new IndyClientModule[modules.size()]));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) SiteConfigBuilder(org.commonjava.util.jhttpc.model.SiteConfigBuilder) Indy(org.commonjava.indy.client.core.Indy) SiteConfig(org.commonjava.util.jhttpc.model.SiteConfig) MemoryPasswordManager(org.commonjava.util.jhttpc.auth.MemoryPasswordManager) IndyClientModule(org.commonjava.indy.client.core.IndyClientModule)

Example 54 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class AutoProxCalculationTest method jsonRoundTrip_HostedRepoCreation.

@Test
public void jsonRoundTrip_HostedRepoCreation() throws IOException {
    HostedRepository repo = new HostedRepository("test");
    AutoProxCalculation in = new AutoProxCalculation(repo, "test-rule.groovy");
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    String json = mapper.writeValueAsString(in);
    AutoProxCalculation out = mapper.readValue(json, AutoProxCalculation.class);
    assertThat(out, notNullValue());
    assertThat(out.getRuleName(), equalTo(in.getRuleName()));
    assertThat(out.getStore(), equalTo(in.getStore()));
    assertThat(out, equalTo(in));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Example 55 with IndyObjectMapper

use of org.commonjava.indy.model.core.io.IndyObjectMapper in project indy by Commonjava.

the class AutoProxCalculationTest method jsonRoundTrip_GroupCreation.

@Test
public void jsonRoundTrip_GroupCreation() throws IOException {
    HostedRepository first = new HostedRepository("first");
    HostedRepository second = new HostedRepository("second");
    Group repo = new Group("test", first.getKey(), second.getKey());
    AutoProxCalculation in = new AutoProxCalculation(repo, Arrays.asList(first, second), "test-rule.groovy");
    IndyObjectMapper mapper = new IndyObjectMapper(true);
    String json = mapper.writeValueAsString(in);
    AutoProxCalculation out = mapper.readValue(json, AutoProxCalculation.class);
    assertThat(out, notNullValue());
    assertThat(out.getRuleName(), equalTo(in.getRuleName()));
    assertThat(out.getStore(), equalTo(in.getStore()));
    assertThat(out, equalTo(in));
    List<ArtifactStore> supplementalStores = out.getSupplementalStores();
    assertThat(supplementalStores, notNullValue());
    assertThat(supplementalStores.size(), equalTo(2));
    assertThat(supplementalStores.get(0), equalTo(first));
    assertThat(supplementalStores.get(1), equalTo(second));
}
Also used : Group(org.commonjava.indy.model.core.Group) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test)

Aggregations

IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)59 Test (org.junit.Test)41 StoreKey (org.commonjava.indy.model.core.StoreKey)16 HostedRepository (org.commonjava.indy.model.core.HostedRepository)10 Group (org.commonjava.indy.model.core.Group)9 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)8 PackageMetadata (org.commonjava.indy.pkg.npm.model.PackageMetadata)8 Transfer (org.commonjava.maven.galley.model.Transfer)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 MemoryStoreDataManager (org.commonjava.indy.mem.data.MemoryStoreDataManager)7 DataFileManager (org.commonjava.indy.subsys.datafile.DataFileManager)6 DataFileEventManager (org.commonjava.indy.subsys.datafile.change.DataFileEventManager)6 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)6 Before (org.junit.Before)6 VersionMetadata (org.commonjava.indy.pkg.npm.model.VersionMetadata)5 MemoryNotFoundCache (org.commonjava.maven.galley.nfc.MemoryNotFoundCache)5 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)4 Indy (org.commonjava.indy.client.core.Indy)4 DirectContentAccess (org.commonjava.indy.content.DirectContentAccess)4 DefaultContentDigester (org.commonjava.indy.core.content.DefaultContentDigester)4