use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ReleaseServiceTest method init.
@Before
public void init() {
firstRelease = new Release();
firstRelease.setId(releaseId);
firstRelease.setAppId(appId);
firstRelease.setClusterName(clusterName);
firstRelease.setNamespaceName(namespaceName);
firstRelease.setAbandoned(false);
secondRelease = new Release();
secondRelease.setAppId(appId);
secondRelease.setClusterName(clusterName);
secondRelease.setNamespaceName(namespaceName);
secondRelease.setAbandoned(false);
pageRequest = PageRequest.of(0, 2);
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ReleaseServiceTest method testFindByReleaseIds.
@Test
public void testFindByReleaseIds() throws Exception {
Release someRelease = mock(Release.class);
Release anotherRelease = mock(Release.class);
long someReleaseId = 1;
long anotherReleaseId = 2;
List<Release> someReleases = Lists.newArrayList(someRelease, anotherRelease);
Set<Long> someReleaseIds = Sets.newHashSet(someReleaseId, anotherReleaseId);
when(releaseRepository.findAllById(someReleaseIds)).thenReturn(someReleases);
List<Release> result = releaseService.findByReleaseIds(someReleaseIds);
assertEquals(someReleases, result);
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ReleaseServiceTest method testRollbackTo.
@Test
public void testRollbackTo() {
List<Release> releaseList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
Release release = new Release();
release.setId(3 - i);
release.setAppId(appId);
release.setClusterName(clusterName);
release.setNamespaceName(namespaceName);
release.setAbandoned(false);
releaseList.add(release);
}
long releaseId1 = 1;
long releaseId3 = 3;
when(releaseRepository.findById(releaseId1)).thenReturn(Optional.of(releaseList.get(2)));
when(releaseRepository.findById(releaseId3)).thenReturn(Optional.of(releaseList.get(0)));
when(releaseRepository.findByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseAndIdBetweenOrderByIdDesc(appId, clusterName, namespaceName, releaseId1, releaseId3)).thenReturn(releaseList);
releaseService.rollbackTo(releaseId3, releaseId1, user);
verify(releaseRepository).saveAll(releaseList);
Assert.assertTrue(releaseList.get(0).isAbandoned());
Assert.assertTrue(releaseList.get(1).isAbandoned());
Assert.assertFalse(releaseList.get(2).isAbandoned());
Assert.assertEquals(user, releaseList.get(0).getDataChangeLastModifiedBy());
Assert.assertEquals(user, releaseList.get(1).getDataChangeLastModifiedBy());
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ReleaseServiceTest method testFindRelease.
@Test
public void testFindRelease() throws Exception {
String someAppId = "1";
String someClusterName = "someClusterName";
String someNamespaceName = "someNamespaceName";
long someReleaseId = 1;
String someReleaseKey = "someKey";
String someValidConfiguration = "{\"apollo.bar\": \"foo\"}";
Release someRelease = MockBeanFactory.mockRelease(someReleaseId, someReleaseKey, someAppId, someClusterName, someNamespaceName, someValidConfiguration);
when(releaseRepository.findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName)).thenReturn(someRelease);
Release result = releaseService.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName);
verify(releaseRepository, times(1)).findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName);
assertEquals(someAppId, result.getAppId());
assertEquals(someClusterName, result.getClusterName());
assertEquals(someReleaseId, result.getId());
assertEquals(someReleaseKey, result.getReleaseKey());
assertEquals(someValidConfiguration, result.getConfigurations());
}
use of com.ctrip.framework.apollo.biz.entity.Release in project apollo by ctripcorp.
the class ReleaseServiceTest method testLoadConfigWithConfigNotFound.
@Test
public void testLoadConfigWithConfigNotFound() throws Exception {
String someAppId = "1";
String someClusterName = "someClusterName";
String someNamespaceName = "someNamespaceName";
when(releaseRepository.findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName)).thenReturn(null);
Release result = releaseService.findLatestActiveRelease(someAppId, someClusterName, someNamespaceName);
assertNull(result);
verify(releaseRepository, times(1)).findFirstByAppIdAndClusterNameAndNamespaceNameAndIsAbandonedFalseOrderByIdDesc(someAppId, someClusterName, someNamespaceName);
}
Aggregations