Search in sources :

Example 1 with Version

use of org.talend.dataprep.info.Version in project data-prep by Talend.

the class VersionServiceAPI method allVersions.

/**
 * Returns all the versions of the different services (api, dataset, preparation and transformation) and the global
 * application version.
 *
 * @return an array of service versions
 */
@RequestMapping(value = "/api/version", method = GET)
@ApiOperation(value = "Get the version of all services (including underlying low level services)", produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
@PublicAPI
public BuildDetails allVersions() {
    List<Version> versions = new ArrayList<>();
    for (VersionsSupplier versionsSupplier : versionsSuppliers) {
        versions.addAll(versionsSupplier.getVersions());
    }
    CollectionUtils.filter(versions, PredicateUtils.notNullPredicate());
    return new BuildDetails(applicationVersion, versions.toArray(new Version[versions.size()]));
}
Also used : BuildDetails(org.talend.dataprep.info.BuildDetails) Version(org.talend.dataprep.info.Version) ArrayList(java.util.ArrayList) VersionsSupplier(org.talend.dataprep.api.service.version.VersionsSupplier) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) PublicAPI(org.talend.dataprep.security.PublicAPI) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Version

use of org.talend.dataprep.info.Version in project data-prep by Talend.

the class VersionServiceTest method shouldAggregateSameBuildId.

@Test
public void shouldAggregateSameBuildId() throws Exception {
    // given
    final ManifestInfoProvider provider1 = mock(ManifestInfoProvider.class);
    final ManifestInfoProvider provider2 = mock(ManifestInfoProvider.class);
    when(provider1.getManifestInfo()).thenReturn(new ManifestInfo("v1", "1234"));
    when(provider2.getManifestInfo()).thenReturn(new ManifestInfo("v1", "1234"));
    ReflectionTestUtils.setField(versionService, "manifestInfoProviders", asList(provider1, provider2));
    // when
    final Version version = versionService.version();
    // then
    assertEquals("v1", version.getVersionId());
    assertEquals("1234-1234", version.getBuildId());
}
Also used : Version(org.talend.dataprep.info.Version) ManifestInfo(org.talend.dataprep.info.ManifestInfo) ManifestInfoProvider(org.talend.dataprep.info.ManifestInfoProvider) Test(org.junit.Test)

Example 3 with Version

use of org.talend.dataprep.info.Version in project data-prep by Talend.

the class VersionServiceTest method shouldAggregateBuildId.

@Test
public void shouldAggregateBuildId() throws Exception {
    // given
    final ManifestInfoProvider provider1 = mock(ManifestInfoProvider.class);
    final ManifestInfoProvider provider2 = mock(ManifestInfoProvider.class);
    when(provider1.getManifestInfo()).thenReturn(new ManifestInfo("v1", "1234"));
    when(provider2.getManifestInfo()).thenReturn(new ManifestInfo("v1", "5678"));
    ReflectionTestUtils.setField(versionService, "manifestInfoProviders", asList(provider1, provider2));
    // when
    final Version version = versionService.version();
    // then
    assertEquals("v1", version.getVersionId());
    assertEquals("1234-5678", version.getBuildId());
}
Also used : Version(org.talend.dataprep.info.Version) ManifestInfo(org.talend.dataprep.info.ManifestInfo) ManifestInfoProvider(org.talend.dataprep.info.ManifestInfoProvider) Test(org.junit.Test)

Example 4 with Version

use of org.talend.dataprep.info.Version in project data-prep by Talend.

the class VersionServiceTest method shouldShouldSkipMissingVersionId.

@Test
public void shouldShouldSkipMissingVersionId() throws Exception {
    // given
    final ManifestInfoProvider provider1 = mock(ManifestInfoProvider.class);
    final ManifestInfoProvider provider2 = mock(ManifestInfoProvider.class);
    when(provider1.getManifestInfo()).thenReturn(new ManifestInfo("v1", "1234"));
    when(provider2.getManifestInfo()).thenReturn(new ManifestInfo("N/A", "1234"));
    ReflectionTestUtils.setField(versionService, "manifestInfoProviders", asList(provider1, provider2));
    // when
    final Version version = versionService.version();
    // then
    assertEquals("v1", version.getVersionId());
    assertEquals("1234-1234", version.getBuildId());
}
Also used : Version(org.talend.dataprep.info.Version) ManifestInfo(org.talend.dataprep.info.ManifestInfo) ManifestInfoProvider(org.talend.dataprep.info.ManifestInfoProvider) Test(org.junit.Test)

Example 5 with Version

use of org.talend.dataprep.info.Version in project data-prep by Talend.

the class VersionServiceTest method shouldAggregateVersionId.

@Test
public void shouldAggregateVersionId() throws Exception {
    // given
    final ManifestInfoProvider provider1 = mock(ManifestInfoProvider.class);
    final ManifestInfoProvider provider2 = mock(ManifestInfoProvider.class);
    when(provider1.getManifestInfo()).thenReturn(new ManifestInfo("v1", "1234"));
    when(provider2.getManifestInfo()).thenReturn(new ManifestInfo("v2", "1234"));
    ReflectionTestUtils.setField(versionService, "manifestInfoProviders", asList(provider1, provider2));
    // when
    final Version version = versionService.version();
    // then
    assertEquals("v1-v2", version.getVersionId());
    assertEquals("1234-1234", version.getBuildId());
}
Also used : Version(org.talend.dataprep.info.Version) ManifestInfo(org.talend.dataprep.info.ManifestInfo) ManifestInfoProvider(org.talend.dataprep.info.ManifestInfoProvider) Test(org.junit.Test)

Aggregations

Version (org.talend.dataprep.info.Version)7 Test (org.junit.Test)4 ManifestInfo (org.talend.dataprep.info.ManifestInfo)4 ManifestInfoProvider (org.talend.dataprep.info.ManifestInfoProvider)4 ArrayList (java.util.ArrayList)2 ApiOperation (io.swagger.annotations.ApiOperation)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 VersionsSupplier (org.talend.dataprep.api.service.version.VersionsSupplier)1 TDPException (org.talend.dataprep.exception.TDPException)1 BuildDetails (org.talend.dataprep.info.BuildDetails)1 Timed (org.talend.dataprep.metrics.Timed)1 PublicAPI (org.talend.dataprep.security.PublicAPI)1