Search in sources :

Example 6 with IndyObjectMapper

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

the class GroupPromoteRequestTest method roundTripJSON_Basic.

@Test
public void roundTripJSON_Basic() throws Exception {
    final IndyObjectMapper mapper = new IndyObjectMapper(true);
    final GroupPromoteRequest req = new GroupPromoteRequest(new StoreKey(StoreType.hosted, "source"), "target");
    final String json = mapper.writeValueAsString(req);
    System.out.println(json);
    final GroupPromoteRequest result = mapper.readValue(json, GroupPromoteRequest.class);
    assertThat(result.getSource(), equalTo(req.getSource()));
    assertThat(result.getTargetGroup(), equalTo(req.getTargetGroup()));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 7 with IndyObjectMapper

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

the class GroupPromoteResultTest method roundTripJSON_NoError.

@Test
public void roundTripJSON_NoError() throws Exception {
    final IndyObjectMapper mapper = new IndyObjectMapper(true);
    final GroupPromoteResult in = new GroupPromoteResult(new GroupPromoteRequest(new StoreKey(StoreType.hosted, "source"), "target"), new ValidationResult());
    final String json = mapper.writeValueAsString(in);
    System.out.println(json);
    final GroupPromoteResult out = mapper.readValue(json, GroupPromoteResult.class);
    // we have separate unit tests to handle serialization checks for PromoteRequest...skipping here.
    assertThat(out.getError(), equalTo(in.getError()));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 8 with IndyObjectMapper

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

the class PathsPromoteRequestTest method roundTripJSON_withPurgeSource.

@Test
public void roundTripJSON_withPurgeSource() throws Exception {
    final IndyObjectMapper mapper = new IndyObjectMapper(true);
    final PathsPromoteRequest req = new PathsPromoteRequest(new StoreKey(StoreType.hosted, "source"), new StoreKey(StoreType.hosted, "target")).setPurgeSource(true);
    final String json = mapper.writeValueAsString(req);
    System.out.println(json);
    final PathsPromoteRequest result = mapper.readValue(json, PathsPromoteRequest.class);
    assertThat(result.getSource(), equalTo(req.getSource()));
    assertThat(result.getTarget(), equalTo(req.getTarget()));
    assertThat(result.isPurgeSource(), equalTo(req.isPurgeSource()));
    assertThat(result.getPaths(), equalTo(req.getPaths()));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 9 with IndyObjectMapper

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

the class PathsPromoteRequestTest method roundTripJSON_withPaths.

@Test
public void roundTripJSON_withPaths() throws Exception {
    final IndyObjectMapper mapper = new IndyObjectMapper(true);
    final PathsPromoteRequest req = new PathsPromoteRequest(new StoreKey(StoreType.hosted, "source"), new StoreKey(StoreType.hosted, "target"), new HashSet<String>(Arrays.asList("/path/one", "/path/two")));
    final String json = mapper.writeValueAsString(req);
    System.out.println(json);
    final PathsPromoteRequest result = mapper.readValue(json, PathsPromoteRequest.class);
    assertThat(result.getSource(), equalTo(req.getSource()));
    assertThat(result.getTarget(), equalTo(req.getTarget()));
    assertThat(result.isPurgeSource(), equalTo(req.isPurgeSource()));
    assertThat(result.getPaths(), equalTo(req.getPaths()));
}
Also used : IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) StoreKey(org.commonjava.indy.model.core.StoreKey) Test(org.junit.Test)

Example 10 with IndyObjectMapper

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

the class TestProvider method init.

@PostConstruct
public void init() {
    try {
        this.storageProviderConfig = new DefaultStorageProviderConfiguration(TEMP.newFolder("storage"));
        this.dataConfig = new DataFileConfiguration(TEMP.newFolder("data"), TEMP.newFolder("work"));
    } catch (final IOException e) {
        e.printStackTrace();
        Assert.fail("Failed to setup temporary directory structures: " + e.getMessage());
    }
    this.nfc = new MemoryNotFoundCache();
    this.xmlInfra = new XMLInfrastructure();
    this.typeMapper = new StandardTypeMapper();
    this.indyConfig = new DefaultIndyConfiguration();
    this.objectMapper = new IndyObjectMapper(true);
}
Also used : DefaultStorageProviderConfiguration(org.commonjava.indy.filer.def.conf.DefaultStorageProviderConfiguration) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) DataFileConfiguration(org.commonjava.indy.subsys.datafile.conf.DataFileConfiguration) XMLInfrastructure(org.commonjava.maven.galley.maven.parse.XMLInfrastructure) MemoryNotFoundCache(org.commonjava.maven.galley.nfc.MemoryNotFoundCache) IOException(java.io.IOException) StandardTypeMapper(org.commonjava.maven.galley.maven.internal.type.StandardTypeMapper) DefaultIndyConfiguration(org.commonjava.indy.conf.DefaultIndyConfiguration) PostConstruct(javax.annotation.PostConstruct)

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