Search in sources :

Example 1 with ChangelogVersionEntry

use of org.nzbhydra.mapping.changelog.ChangelogVersionEntry in project nzbhydra2 by theotherp.

the class UpdateManagerTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
    testee.currentVersionString = "1.0.0";
    testee.repositoryBaseUrl = "http:/127.0.0.1:7070/repos/theotherp/apitests";
    testee.changelogUrl = "http:/127.0.0.1:7070/changelog";
    testee.blockedVersionsUrl = "http:/127.0.0.1:7070/blockedVersions.json";
    testee.afterPropertiesSet();
    Release latestRelease = new Release();
    latestRelease.setTagName("v2.0.0");
    latestRelease.setBody("Some new stuff");
    Release previousRelease = new Release();
    previousRelease.setTagName("v1.0.0");
    previousRelease.setBody("A list:\n" + "* a\n" + "* b");
    when(webAccessMock.callUrl(startsWith("http:/127.0.0.1:7070/repos/theotherp/apitests/releases/latest"), any(), any())).thenReturn(latestRelease);
    // Return in wrong order to test sorting of releases by version
    when(webAccessMock.callUrl(eq("http:/127.0.0.1:7070/repos/theotherp/apitests/releases"), any(), any())).thenReturn(Arrays.asList(previousRelease, latestRelease));
    when(webAccessMock.callUrl(eq("http:/127.0.0.1:7070/changelog"), any(TypeReference.class))).thenReturn(Arrays.asList(new ChangelogVersionEntry("3.0.0", Arrays.asList(new ChangelogChangeEntry("note", "a note"))), new ChangelogVersionEntry("2.0.0", Arrays.asList(new ChangelogChangeEntry("fix", "a minor fix"))), new ChangelogVersionEntry("0.0.1", Arrays.asList(new ChangelogChangeEntry("feature", "a new feature")))));
    when(webAccessMock.callUrl(eq("http:/127.0.0.1:7070/blockedVersions.json"), any(TypeReference.class))).thenReturn(Arrays.asList(new BlockedVersion("3.0.0", "comment")));
}
Also used : ChangelogChangeEntry(org.nzbhydra.mapping.changelog.ChangelogChangeEntry) ChangelogVersionEntry(org.nzbhydra.mapping.changelog.ChangelogVersionEntry) TypeReference(com.fasterxml.jackson.core.type.TypeReference) BlockedVersion(org.nzbhydra.update.UpdateManager.BlockedVersion) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Release(org.nzbhydra.mapping.github.Release) Before(org.junit.Before)

Example 2 with ChangelogVersionEntry

use of org.nzbhydra.mapping.changelog.ChangelogVersionEntry in project nzbhydra2 by theotherp.

the class UpdateManager method getChangesSinceCurrentVersion.

public List<ChangelogVersionEntry> getChangesSinceCurrentVersion() throws UpdateException {
    if (latestVersion == null) {
        getLatestVersion();
    }
    List<ChangelogVersionEntry> allChanges = getAllChanges();
    List<ChangelogVersionEntry> collectedVersionChanges = new ArrayList<>();
    for (ChangelogVersionEntry changelogVersionEntry : allChanges) {
        SemanticVersion version = new SemanticVersion(changelogVersionEntry.getVersion());
        if (currentVersion.isSameOrNewer(version)) {
            break;
        }
        if (version.isUpdateFor(latestVersion)) {
            // Don't show changes for version not yet released
            continue;
        }
        collectedVersionChanges.add(changelogVersionEntry);
    }
    return collectedVersionChanges;
}
Also used : ChangelogVersionEntry(org.nzbhydra.mapping.changelog.ChangelogVersionEntry) SemanticVersion(org.nzbhydra.mapping.SemanticVersion)

Example 3 with ChangelogVersionEntry

use of org.nzbhydra.mapping.changelog.ChangelogVersionEntry in project nzbhydra2 by theotherp.

the class UpdateManagerTest method shouldGetChangesSince.

@Test
public void shouldGetChangesSince() throws Exception {
    testee.latestVersion = new SemanticVersion(2, 0, 0);
    List<ChangelogVersionEntry> changesSince = testee.getChangesSinceCurrentVersion();
    assertEquals(1, changesSince.size());
    // Skip 1.0.0 because it's older and skip 3.0.0 because it's not yet released
    assertEquals("2.0.0", changesSince.get(0).getVersion());
}
Also used : ChangelogVersionEntry(org.nzbhydra.mapping.changelog.ChangelogVersionEntry) SemanticVersion(org.nzbhydra.mapping.SemanticVersion) Test(org.junit.Test)

Aggregations

ChangelogVersionEntry (org.nzbhydra.mapping.changelog.ChangelogVersionEntry)3 SemanticVersion (org.nzbhydra.mapping.SemanticVersion)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ChangelogChangeEntry (org.nzbhydra.mapping.changelog.ChangelogChangeEntry)1 Release (org.nzbhydra.mapping.github.Release)1 BlockedVersion (org.nzbhydra.update.UpdateManager.BlockedVersion)1