Commit df1c73b7 authored by Jason Song's avatar Jason Song

Change appid data type to String

parent 29858d70
...@@ -18,7 +18,7 @@ public class ClusterController { ...@@ -18,7 +18,7 @@ public class ClusterController {
private AdminConfigService adminConfigService; private AdminConfigService adminConfigService;
@RequestMapping("/app/{appId}") @RequestMapping("/app/{appId}")
public List<ClusterDTO> findClustersByApp(@PathVariable long appId) { public List<ClusterDTO> findClustersByApp(@PathVariable String appId) {
return adminConfigService.findClustersByApp(appId); return adminConfigService.findClustersByApp(appId);
} }
} }
...@@ -18,7 +18,7 @@ public class VersionController { ...@@ -18,7 +18,7 @@ public class VersionController {
private AdminConfigService adminConfigService; private AdminConfigService adminConfigService;
@RequestMapping("/app/{appId}") @RequestMapping("/app/{appId}")
public List<VersionDTO> versions(@PathVariable long appId) { public List<VersionDTO> versions(@PathVariable String appId) {
return adminConfigService.findVersionsByApp(appId); return adminConfigService.findVersionsByApp(appId);
} }
......
...@@ -25,7 +25,7 @@ public class Cluster { ...@@ -25,7 +25,7 @@ public class Cluster {
private String name; private String name;
@Column(nullable = false) @Column(nullable = false)
private long appId; private String appId;
private boolean isDeleted; private boolean isDeleted;
...@@ -48,11 +48,11 @@ public class Cluster { ...@@ -48,11 +48,11 @@ public class Cluster {
this.name = name; this.name = name;
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
......
...@@ -26,7 +26,7 @@ public class ConfigItem { ...@@ -26,7 +26,7 @@ public class ConfigItem {
private String clusterName; private String clusterName;
@Column(nullable = false) @Column(nullable = false)
private long appId; private String appId;
@Column(nullable = false) @Column(nullable = false)
private String key; private String key;
...@@ -76,11 +76,11 @@ public class ConfigItem { ...@@ -76,11 +76,11 @@ public class ConfigItem {
this.clusterName = clusterName; this.clusterName = clusterName;
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
......
...@@ -19,7 +19,7 @@ public class Release { ...@@ -19,7 +19,7 @@ public class Release {
private long id; private long id;
private String name; private String name;
private long appId; private String appId;
private String comment; private String comment;
private boolean isDeleted; private boolean isDeleted;
...@@ -42,11 +42,11 @@ public class Release { ...@@ -42,11 +42,11 @@ public class Release {
this.name = name; this.name = name;
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
......
...@@ -23,7 +23,7 @@ public class Version { ...@@ -23,7 +23,7 @@ public class Version {
private String name; private String name;
@Column(nullable = false) @Column(nullable = false)
private long appId; private String appId;
@Column(nullable = false) @Column(nullable = false)
private long releaseId; private long releaseId;
...@@ -50,11 +50,11 @@ public class Version { ...@@ -50,11 +50,11 @@ public class Version {
this.name = name; this.name = name;
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
......
...@@ -9,6 +9,6 @@ import java.util.List; ...@@ -9,6 +9,6 @@ import java.util.List;
public interface ClusterRepository extends PagingAndSortingRepository<Cluster, Long> { public interface ClusterRepository extends PagingAndSortingRepository<Cluster, Long> {
List<Cluster> findByAppId(long appId); List<Cluster> findByAppId(String appId);
} }
...@@ -10,9 +10,9 @@ import java.util.List; ...@@ -10,9 +10,9 @@ import java.util.List;
* @author Jason Song(song_s@ctrip.com) * @author Jason Song(song_s@ctrip.com)
*/ */
public interface VersionRepository extends PagingAndSortingRepository<Version, Long> { public interface VersionRepository extends PagingAndSortingRepository<Version, Long> {
Version findByAppIdAndName(long appId, String name); Version findByAppIdAndName(String appId, String name);
Version findById(long id); Version findById(long id);
List<Version> findByAppId(long appId); List<Version> findByAppId(String appId);
} }
...@@ -14,11 +14,11 @@ public interface AdminConfigService { ...@@ -14,11 +14,11 @@ public interface AdminConfigService {
List<ReleaseSnapshotDTO> findReleaseSnapshotByReleaseId(long releaseId); List<ReleaseSnapshotDTO> findReleaseSnapshotByReleaseId(long releaseId);
List<VersionDTO> findVersionsByApp(long appId); List<VersionDTO> findVersionsByApp(String appId);
VersionDTO loadVersionById(long versionId); VersionDTO loadVersionById(long versionId);
List<ClusterDTO> findClustersByApp(long appId); List<ClusterDTO> findClustersByApp(String appId);
List<ConfigItemDTO> findConfigItemsByClusters(List<Long> clusterIds); List<ConfigItemDTO> findConfigItemsByClusters(List<Long> clusterIds);
......
...@@ -12,12 +12,12 @@ public interface ConfigService { ...@@ -12,12 +12,12 @@ public interface ConfigService {
/** /**
* Load configuration from database * Load configuration from database
*/ */
ApolloConfig loadConfig(long appId, String clusterName, String versionName); ApolloConfig loadConfig(String appId, String clusterName, String versionName);
/** /**
* Load Version by appId and versionName from database * Load Version by appId and versionName from database
*/ */
Version loadVersionByAppIdAndVersionName(long appId, String versionName); Version loadVersionByAppIdAndVersionName(String appId, String versionName);
/** /**
* Load Config by version and clusterName from database * Load Config by version and clusterName from database
......
package com.ctrip.apollo.biz.service.impl; package com.ctrip.apollo.biz.service.impl;
import com.google.common.base.Strings;
import com.ctrip.apollo.biz.entity.Cluster; import com.ctrip.apollo.biz.entity.Cluster;
import com.ctrip.apollo.biz.entity.ConfigItem; import com.ctrip.apollo.biz.entity.ConfigItem;
import com.ctrip.apollo.biz.entity.ReleaseSnapshot; import com.ctrip.apollo.biz.entity.ReleaseSnapshot;
...@@ -50,8 +52,8 @@ public class AdminConfigServiceImpl implements AdminConfigService { ...@@ -50,8 +52,8 @@ public class AdminConfigServiceImpl implements AdminConfigService {
@Override @Override
public List<VersionDTO> findVersionsByApp(long appId) { public List<VersionDTO> findVersionsByApp(String appId) {
if (appId <= 0) { if (Strings.isNullOrEmpty(appId)) {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
...@@ -77,8 +79,8 @@ public class AdminConfigServiceImpl implements AdminConfigService { ...@@ -77,8 +79,8 @@ public class AdminConfigServiceImpl implements AdminConfigService {
} }
@Override @Override
public List<ClusterDTO> findClustersByApp(long appId) { public List<ClusterDTO> findClustersByApp(String appId) {
if (appId <= 0) { if (Strings.isNullOrEmpty(appId)) {
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
} }
List<Cluster> clusters = clusterRepository.findByAppId(appId); List<Cluster> clusters = clusterRepository.findByAppId(appId);
......
...@@ -33,7 +33,7 @@ public class ConfigServiceImpl implements ConfigService { ...@@ -33,7 +33,7 @@ public class ConfigServiceImpl implements ConfigService {
}; };
@Override @Override
public ApolloConfig loadConfig(long appId, String clusterName, String versionName) { public ApolloConfig loadConfig(String appId, String clusterName, String versionName) {
Version version = loadVersionByAppIdAndVersionName(appId, versionName); Version version = loadVersionByAppIdAndVersionName(appId, versionName);
if (version == null) { if (version == null) {
return null; return null;
...@@ -43,7 +43,7 @@ public class ConfigServiceImpl implements ConfigService { ...@@ -43,7 +43,7 @@ public class ConfigServiceImpl implements ConfigService {
} }
@Override @Override
public Version loadVersionByAppIdAndVersionName(long appId, String versionName) { public Version loadVersionByAppIdAndVersionName(String appId, String versionName) {
return versionRepository.findByAppIdAndName(appId, versionName); return versionRepository.findByAppIdAndName(appId, versionName);
} }
......
...@@ -53,7 +53,7 @@ public class ConfigServiceImplTest { ...@@ -53,7 +53,7 @@ public class ConfigServiceImplTest {
@Test @Test
public void testLoadConfig() throws Exception { public void testLoadConfig() throws Exception {
long someAppId = 1; String someAppId = "1";
String someClusterName = "someClusterName"; String someClusterName = "someClusterName";
String someVersionName = "someVersionName"; String someVersionName = "someVersionName";
long someReleaseId = 1; long someReleaseId = 1;
...@@ -82,7 +82,7 @@ public class ConfigServiceImplTest { ...@@ -82,7 +82,7 @@ public class ConfigServiceImplTest {
@Test @Test
public void testLoadConfigWithVersionNotFound() throws Exception { public void testLoadConfigWithVersionNotFound() throws Exception {
long someAppId = 1; String someAppId = "1";
String someClusterName = "someClusterName"; String someClusterName = "someClusterName";
String someVersionName = "someVersionName"; String someVersionName = "someVersionName";
...@@ -96,7 +96,7 @@ public class ConfigServiceImplTest { ...@@ -96,7 +96,7 @@ public class ConfigServiceImplTest {
@Test @Test
public void testLoadConfigWithConfigNotFound() throws Exception { public void testLoadConfigWithConfigNotFound() throws Exception {
long someAppId = 1; String someAppId = "1";
String someClusterName = "someClusterName"; String someClusterName = "someClusterName";
String someVersionName = "someVersionName"; String someVersionName = "someVersionName";
long someReleaseId = 1; long someReleaseId = 1;
...@@ -114,7 +114,7 @@ public class ConfigServiceImplTest { ...@@ -114,7 +114,7 @@ public class ConfigServiceImplTest {
.findByReleaseIdAndClusterName(someReleaseId, someClusterName); .findByReleaseIdAndClusterName(someReleaseId, someClusterName);
} }
private Version assembleVersion(long appId, String versionName, long releaseId) { private Version assembleVersion(String appId, String versionName, long releaseId) {
Version version = new Version(); Version version = new Version();
version.setAppId(appId); version.setAppId(appId);
version.setName(versionName); version.setName(versionName);
......
...@@ -17,7 +17,7 @@ public class ClientEnvironment { ...@@ -17,7 +17,7 @@ public class ClientEnvironment {
private static final Logger logger = LoggerFactory.getLogger(ClientEnvironment.class); private static final Logger logger = LoggerFactory.getLogger(ClientEnvironment.class);
private static final String DEFAULT_FILE = "/apollo.properties"; private static final String DEFAULT_FILE = "apollo.properties";
private AtomicReference<Env> env = new AtomicReference<Env>(); private AtomicReference<Env> env = new AtomicReference<Env>();
......
...@@ -188,7 +188,7 @@ public class ConfigLoaderManager { ...@@ -188,7 +188,7 @@ public class ConfigLoaderManager {
} }
private String assemblePropertySourceName(ApolloConfig apolloConfig) { private String assemblePropertySourceName(ApolloConfig apolloConfig) {
return String.format("%d-%s-%s-%d", apolloConfig.getAppId(), apolloConfig.getCluster(), return String.format("%s-%s-%s-%d", apolloConfig.getAppId(), apolloConfig.getCluster(),
apolloConfig.getVersion(), apolloConfig.getReleaseId()); apolloConfig.getVersion(), apolloConfig.getReleaseId());
} }
} }
...@@ -40,7 +40,7 @@ public class RemoteConfigLoader extends AbstractConfigLoader { ...@@ -40,7 +40,7 @@ public class RemoteConfigLoader extends AbstractConfigLoader {
ApolloConfig getRemoteConfig(RestTemplate restTemplate, String uri, String cluster, ApolloConfig getRemoteConfig(RestTemplate restTemplate, String uri, String cluster,
ApolloRegistry apolloRegistry, ApolloConfig previousConfig) { ApolloRegistry apolloRegistry, ApolloConfig previousConfig) {
long appId = apolloRegistry.getAppId(); String appId = apolloRegistry.getAppId();
String version = apolloRegistry.getVersion(); String version = apolloRegistry.getVersion();
logger.info("Loading config from {}, appId={}, cluster={}, version={}", uri, appId, cluster, logger.info("Loading config from {}, appId={}, cluster={}, version={}", uri, appId, cluster,
......
...@@ -6,14 +6,14 @@ import com.google.common.base.MoreObjects; ...@@ -6,14 +6,14 @@ import com.google.common.base.MoreObjects;
* @author Jason Song(song_s@ctrip.com) * @author Jason Song(song_s@ctrip.com)
*/ */
public class ApolloRegistry { public class ApolloRegistry {
private long appId; private String appId;
private String version; private String version;
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
......
...@@ -67,7 +67,7 @@ public class ConfigUtil { ...@@ -67,7 +67,7 @@ public class ConfigUtil {
return null; return null;
} }
ApolloRegistry registry = new ApolloRegistry(); ApolloRegistry registry = new ApolloRegistry();
registry.setAppId(Long.parseLong(properties.getProperty(Constants.APP_ID))); registry.setAppId(properties.getProperty(Constants.APP_ID));
registry.setVersion( registry.setVersion(
properties.getProperty(Constants.VERSION, Constants.DEFAULT_VERSION_NAME)); properties.getProperty(Constants.VERSION, Constants.DEFAULT_VERSION_NAME));
return registry; return registry;
......
...@@ -51,8 +51,8 @@ public class ConfigLoaderManagerTest { ...@@ -51,8 +51,8 @@ public class ConfigLoaderManagerTest {
@Test @Test
public void testLoadPropertySource() throws Exception { public void testLoadPropertySource() throws Exception {
long someAppId = 100; String someAppId = "100";
long anotherAppId = 101; String anotherAppId = "101";
ApolloRegistry someApolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion"); ApolloRegistry someApolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion");
ApolloRegistry ApolloRegistry
anotherApolloRegistry = anotherApolloRegistry =
...@@ -92,7 +92,7 @@ public class ConfigLoaderManagerTest { ...@@ -92,7 +92,7 @@ public class ConfigLoaderManagerTest {
@Test(expected = RuntimeException.class) @Test(expected = RuntimeException.class)
public void testLoadPropertySourceWithError() throws Exception { public void testLoadPropertySourceWithError() throws Exception {
Exception someException = mock(Exception.class); Exception someException = mock(Exception.class);
long someAppId = 100; String someAppId = "100";
ApolloRegistry someApolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion"); ApolloRegistry someApolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion");
when(configUtil.loadApolloRegistries()).thenReturn(Lists.newArrayList(someApolloRegistry)); when(configUtil.loadApolloRegistries()).thenReturn(Lists.newArrayList(someApolloRegistry));
...@@ -114,7 +114,7 @@ public class ConfigLoaderManagerTest { ...@@ -114,7 +114,7 @@ public class ConfigLoaderManagerTest {
public void testLoadSingleApolloConfig() throws Exception { public void testLoadSingleApolloConfig() throws Exception {
ApolloConfig someApolloConfig = mock(ApolloConfig.class); ApolloConfig someApolloConfig = mock(ApolloConfig.class);
Map<String, Object> someMap = Maps.newHashMap(); Map<String, Object> someMap = Maps.newHashMap();
long someAppId = 100; String someAppId = "100";
ApolloRegistry someApolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion"); ApolloRegistry someApolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion");
ApolloConfig previousConfig = null; ApolloConfig previousConfig = null;
...@@ -130,7 +130,7 @@ public class ConfigLoaderManagerTest { ...@@ -130,7 +130,7 @@ public class ConfigLoaderManagerTest {
@Test @Test
public void testReloadPropertySource() throws Exception { public void testReloadPropertySource() throws Exception {
long someAppId = 100; String someAppId = "100";
ApolloRegistry someApolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion"); ApolloRegistry someApolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion");
ApolloConfig someApolloConfig = mock(ApolloConfig.class); ApolloConfig someApolloConfig = mock(ApolloConfig.class);
Map<String, Object> someMap = mock(Map.class); Map<String, Object> someMap = mock(Map.class);
...@@ -162,7 +162,7 @@ public class ConfigLoaderManagerTest { ...@@ -162,7 +162,7 @@ public class ConfigLoaderManagerTest {
@Test @Test
public void testCalcPropertyChanges() throws Exception { public void testCalcPropertyChanges() throws Exception {
long someAppId = 1; String someAppId = "1";
Map<String, Object> someConfig = Maps.newHashMap(); Map<String, Object> someConfig = Maps.newHashMap();
someConfig.put("key1", "val1"); someConfig.put("key1", "val1");
someConfig.put("key2", "val2"); someConfig.put("key2", "val2");
...@@ -195,7 +195,7 @@ public class ConfigLoaderManagerTest { ...@@ -195,7 +195,7 @@ public class ConfigLoaderManagerTest {
))); )));
} }
ApolloConfig assembleApolloConfig(long appId, Map<String, Object> configurations) { ApolloConfig assembleApolloConfig(String appId, Map<String, Object> configurations) {
String someCluster = "someCluster"; String someCluster = "someCluster";
String someVersion = "someVersion"; String someVersion = "someVersion";
long someReleaseId = 1; long someReleaseId = 1;
...@@ -207,7 +207,7 @@ public class ConfigLoaderManagerTest { ...@@ -207,7 +207,7 @@ public class ConfigLoaderManagerTest {
return config; return config;
} }
private ApolloRegistry assembleSomeApolloRegistry(long someAppId, String someVersion) { private ApolloRegistry assembleSomeApolloRegistry(String someAppId, String someVersion) {
ApolloRegistry someApolloRegistry = new ApolloRegistry(); ApolloRegistry someApolloRegistry = new ApolloRegistry();
someApolloRegistry.setAppId(someAppId); someApolloRegistry.setAppId(someAppId);
someApolloRegistry.setVersion(someVersion); someApolloRegistry.setVersion(someVersion);
......
...@@ -56,7 +56,7 @@ public class RemoteConfigLoaderTest { ...@@ -56,7 +56,7 @@ public class RemoteConfigLoaderTest {
String someServerUrl = "http://someUrl"; String someServerUrl = "http://someUrl";
String someCluster = "some cluster"; String someCluster = "some cluster";
ApolloConfig apolloConfig = mock(ApolloConfig.class); ApolloConfig apolloConfig = mock(ApolloConfig.class);
long someAppId = 1; String someAppId = "1";
ApolloRegistry apolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion"); ApolloRegistry apolloRegistry = assembleSomeApolloRegistry(someAppId, "someVersion");
ApolloConfig previousConfig = null; ApolloConfig previousConfig = null;
...@@ -76,7 +76,7 @@ public class RemoteConfigLoaderTest { ...@@ -76,7 +76,7 @@ public class RemoteConfigLoaderTest {
@Test @Test
public void testGetRemoteConfig() throws Exception { public void testGetRemoteConfig() throws Exception {
long someAppId = 1; String someAppId = "1";
String someServerUrl = "http://someServer"; String someServerUrl = "http://someServer";
String someClusterName = "someCluster"; String someClusterName = "someCluster";
String someVersionName = "someVersion"; String someVersionName = "someVersion";
...@@ -100,7 +100,7 @@ public class RemoteConfigLoaderTest { ...@@ -100,7 +100,7 @@ public class RemoteConfigLoaderTest {
@Test(expected = RuntimeException.class) @Test(expected = RuntimeException.class)
public void testGetRemoteConfigWithServerError() throws Exception { public void testGetRemoteConfigWithServerError() throws Exception {
long someAppId = 1; String someAppId = "1";
String someServerUrl = "http://someServer"; String someServerUrl = "http://someServer";
String someClusterName = "someCluster"; String someClusterName = "someCluster";
String someVersionName = "someVersion"; String someVersionName = "someVersion";
...@@ -118,7 +118,7 @@ public class RemoteConfigLoaderTest { ...@@ -118,7 +118,7 @@ public class RemoteConfigLoaderTest {
@Test @Test
public void testGetRemoteConfigWith304Response() throws Exception { public void testGetRemoteConfigWith304Response() throws Exception {
long someAppId = 1; String someAppId = "1";
String someServerUrl = "http://someServer"; String someServerUrl = "http://someServer";
String someClusterName = "someCluster"; String someClusterName = "someCluster";
String someVersionName = "someVersion"; String someVersionName = "someVersion";
...@@ -138,7 +138,7 @@ public class RemoteConfigLoaderTest { ...@@ -138,7 +138,7 @@ public class RemoteConfigLoaderTest {
assertNull(result); assertNull(result);
} }
private ApolloRegistry assembleSomeApolloRegistry(long someAppId, String someVersion) { private ApolloRegistry assembleSomeApolloRegistry(String someAppId, String someVersion) {
ApolloRegistry someApolloRegistry = new ApolloRegistry(); ApolloRegistry someApolloRegistry = new ApolloRegistry();
someApolloRegistry.setAppId(someAppId); someApolloRegistry.setAppId(someAppId);
someApolloRegistry.setVersion(someVersion); someApolloRegistry.setVersion(someVersion);
......
...@@ -60,7 +60,7 @@ public class ConfigUtilTest { ...@@ -60,7 +60,7 @@ public class ConfigUtilTest {
ApolloRegistry apolloRegistry = apolloRegistries.get(0); ApolloRegistry apolloRegistry = apolloRegistries.get(0);
assertEquals(1, apolloRegistries.size()); assertEquals(1, apolloRegistries.size());
assertEquals(Long.parseLong(someAppId), apolloRegistry.getAppId()); assertEquals(someAppId, apolloRegistry.getAppId());
assertEquals(someVersionId, apolloRegistry.getVersion()); assertEquals(someVersionId, apolloRegistry.getVersion());
} }
......
...@@ -25,7 +25,7 @@ public class ConfigController { ...@@ -25,7 +25,7 @@ public class ConfigController {
private ConfigService configService; private ConfigService configService;
@RequestMapping(value = "/{appId}/{clusterName}/{versionName:.*}", method = RequestMethod.GET) @RequestMapping(value = "/{appId}/{clusterName}/{versionName:.*}", method = RequestMethod.GET)
public ApolloConfig queryConfig(@PathVariable long appId, public ApolloConfig queryConfig(@PathVariable String appId,
@PathVariable String clusterName, @PathVariable String clusterName,
@PathVariable String versionName, @PathVariable String versionName,
@RequestParam(value = "releaseId", defaultValue = "-1") long clientSideReleaseId, @RequestParam(value = "releaseId", defaultValue = "-1") long clientSideReleaseId,
...@@ -33,7 +33,7 @@ public class ConfigController { ...@@ -33,7 +33,7 @@ public class ConfigController {
Version version = configService.loadVersionByAppIdAndVersionName(appId, versionName); Version version = configService.loadVersionByAppIdAndVersionName(appId, versionName);
if (version == null) { if (version == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, response.sendError(HttpServletResponse.SC_NOT_FOUND,
String.format("Could not load version with appId: %d, versionName: %s", appId, String.format("Could not load version with appId: %s, versionName: %s", appId,
versionName)); versionName));
return null; return null;
} }
......
...@@ -42,7 +42,7 @@ public class ConfigControllerTest { ...@@ -42,7 +42,7 @@ public class ConfigControllerTest {
@Test @Test
public void testQueryConfig() throws Exception { public void testQueryConfig() throws Exception {
ApolloConfig someApolloConfig = mock(ApolloConfig.class); ApolloConfig someApolloConfig = mock(ApolloConfig.class);
long someAppId = 1; String someAppId = "1";
String someClusterName = "someClusterName"; String someClusterName = "someClusterName";
String someVersionName = "someVersion"; String someVersionName = "someVersion";
long someClientSideReleaseId = 1; long someClientSideReleaseId = 1;
...@@ -69,7 +69,7 @@ public class ConfigControllerTest { ...@@ -69,7 +69,7 @@ public class ConfigControllerTest {
@Test @Test
public void testQueryConfigWithVersionNotFound() throws Exception { public void testQueryConfigWithVersionNotFound() throws Exception {
long someAppId = 1; String someAppId = "1";
String someClusterName = "someClusterName"; String someClusterName = "someClusterName";
String someVersionName = "someVersion"; String someVersionName = "someVersion";
long someClientSideReleaseId = 1; long someClientSideReleaseId = 1;
...@@ -90,7 +90,7 @@ public class ConfigControllerTest { ...@@ -90,7 +90,7 @@ public class ConfigControllerTest {
@Test @Test
public void testQueryConfigWithApolloConfigNotFound() throws Exception { public void testQueryConfigWithApolloConfigNotFound() throws Exception {
long someAppId = 1; String someAppId = "1";
String someClusterName = "someClusterName"; String someClusterName = "someClusterName";
String someVersionName = "someVersion"; String someVersionName = "someVersion";
long someClientSideReleaseId = 1; long someClientSideReleaseId = 1;
...@@ -116,7 +116,7 @@ public class ConfigControllerTest { ...@@ -116,7 +116,7 @@ public class ConfigControllerTest {
@Test @Test
public void testQueryConfigWithApolloConfigNotModified() throws Exception { public void testQueryConfigWithApolloConfigNotModified() throws Exception {
long someAppId = 1; String someAppId = "1";
String someClusterName = "someClusterName"; String someClusterName = "someClusterName";
String someVersionName = "someVersion"; String someVersionName = "someVersion";
long someClientSideReleaseId = 1; long someClientSideReleaseId = 1;
......
...@@ -12,7 +12,7 @@ import java.util.Map; ...@@ -12,7 +12,7 @@ import java.util.Map;
*/ */
public class ApolloConfig implements Comparable<ApolloConfig> { public class ApolloConfig implements Comparable<ApolloConfig> {
private long appId; private String appId;
private String cluster; private String cluster;
...@@ -25,7 +25,7 @@ public class ApolloConfig implements Comparable<ApolloConfig> { ...@@ -25,7 +25,7 @@ public class ApolloConfig implements Comparable<ApolloConfig> {
private int order; private int order;
@JsonCreator @JsonCreator
public ApolloConfig(@JsonProperty("appId") long appId, public ApolloConfig(@JsonProperty("appId") String appId,
@JsonProperty("cluster") String cluster, @JsonProperty("cluster") String cluster,
@JsonProperty("version") String version, @JsonProperty("version") String version,
@JsonProperty("releaseId") long releaseId) { @JsonProperty("releaseId") long releaseId) {
...@@ -44,7 +44,7 @@ public class ApolloConfig implements Comparable<ApolloConfig> { ...@@ -44,7 +44,7 @@ public class ApolloConfig implements Comparable<ApolloConfig> {
this.configurations = configurations; this.configurations = configurations;
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
......
...@@ -6,7 +6,7 @@ public class ClusterDTO { ...@@ -6,7 +6,7 @@ public class ClusterDTO {
private String name; private String name;
private long appId; private String appId;
public long getId() { public long getId() {
return id; return id;
...@@ -24,11 +24,11 @@ public class ClusterDTO { ...@@ -24,11 +24,11 @@ public class ClusterDTO {
this.name = name; this.name = name;
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
} }
...@@ -10,7 +10,7 @@ public class ConfigItemDTO { ...@@ -10,7 +10,7 @@ public class ConfigItemDTO {
private String clusterName; private String clusterName;
private long appId; private String appId;
private String key; private String key;
...@@ -59,11 +59,11 @@ public class ConfigItemDTO { ...@@ -59,11 +59,11 @@ public class ConfigItemDTO {
this.clusterName = clusterName; this.clusterName = clusterName;
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
......
...@@ -6,7 +6,7 @@ public class VersionDTO { ...@@ -6,7 +6,7 @@ public class VersionDTO {
private String name; private String name;
private long appId; private String appId;
private long releaseId; private long releaseId;
...@@ -32,11 +32,11 @@ public class VersionDTO { ...@@ -32,11 +32,11 @@ public class VersionDTO {
this.name = name; this.name = name;
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
......
package com.ctrip.apollo.portal.api; package com.ctrip.apollo.portal.api;
import com.google.common.base.Strings;
import com.ctrip.apollo.Apollo; import com.ctrip.apollo.Apollo;
import com.ctrip.apollo.core.dto.ClusterDTO; import com.ctrip.apollo.core.dto.ClusterDTO;
import com.ctrip.apollo.core.dto.ConfigItemDTO; import com.ctrip.apollo.core.dto.ConfigItemDTO;
...@@ -45,8 +47,8 @@ public class AdminServiceAPI { ...@@ -45,8 +47,8 @@ public class AdminServiceAPI {
public static String CLUSTER_APP_API = "/cluster/app/"; public static String CLUSTER_APP_API = "/cluster/app/";
public ClusterDTO[] getClustersByApp(Apollo.Env env, long appId) { public ClusterDTO[] getClustersByApp(Apollo.Env env, String appId) {
if (appId <= 0) { if (Strings.isNullOrEmpty(appId)) {
return null; return null;
} }
...@@ -68,8 +70,8 @@ public class AdminServiceAPI { ...@@ -68,8 +70,8 @@ public class AdminServiceAPI {
return restTemplate.getForObject(getAdminServiceHost(env) + VERSION_API + versionId, VersionDTO.class); return restTemplate.getForObject(getAdminServiceHost(env) + VERSION_API + versionId, VersionDTO.class);
} }
public VersionDTO[] getVersionsByApp(Apollo.Env env, long appId){ public VersionDTO[] getVersionsByApp(Apollo.Env env, String appId){
if (appId <= 0){ if (Strings.isNullOrEmpty(appId)){
return null; return null;
} }
return restTemplate.getForObject(getAdminServiceHost(env) + VERSION_APP_API + appId, return restTemplate.getForObject(getAdminServiceHost(env) + VERSION_APP_API + appId,
......
...@@ -28,7 +28,7 @@ public class AppController { ...@@ -28,7 +28,7 @@ public class AppController {
} }
@RequestMapping("/{appid}") @RequestMapping("/{appid}")
public App detail(@PathVariable long appid) { public App detail(@PathVariable String appid) {
App app = appService.detail(appid); App app = appService.detail(appid);
if (app == null) { if (app == null) {
throw new NotFoundException(); throw new NotFoundException();
......
package com.ctrip.apollo.portal.controller; package com.ctrip.apollo.portal.controller;
import com.google.common.base.Strings;
import com.ctrip.apollo.Apollo; import com.ctrip.apollo.Apollo;
import com.ctrip.apollo.portal.constants.PortalConstants; import com.ctrip.apollo.portal.constants.PortalConstants;
import com.ctrip.apollo.portal.entity.AppConfigVO; import com.ctrip.apollo.portal.entity.AppConfigVO;
...@@ -19,10 +21,10 @@ public class ConfigController { ...@@ -19,10 +21,10 @@ public class ConfigController {
private ConfigService configService; private ConfigService configService;
@RequestMapping("/{appId}/{env}/{versionId}") @RequestMapping("/{appId}/{env}/{versionId}")
public AppConfigVO detail(@PathVariable long appId, @PathVariable String env, public AppConfigVO detail(@PathVariable String appId, @PathVariable String env,
@PathVariable long versionId) { @PathVariable long versionId) {
if (appId <= 0) { if (Strings.isNullOrEmpty(appId)) {
throw new NotFoundException(); throw new NotFoundException();
} }
......
...@@ -19,7 +19,7 @@ public class VersionController { ...@@ -19,7 +19,7 @@ public class VersionController {
private VersionService versionService; private VersionService versionService;
@RequestMapping("/{appId}/{env}") @RequestMapping("/{appId}/{env}")
public List<VersionDTO> versions(@PathVariable long appId, @PathVariable String env) { public List<VersionDTO> versions(@PathVariable String appId, @PathVariable String env) {
return versionService.findVersionsByApp(Apollo.Env.DEV, appId); return versionService.findVersionsByApp(Apollo.Env.DEV, appId);
} }
} }
...@@ -16,7 +16,7 @@ public class App implements Serializable { ...@@ -16,7 +16,7 @@ public class App implements Serializable {
private static final long serialVersionUID = 7348554309210401557L; private static final long serialVersionUID = 7348554309210401557L;
@Id @Id
private long appId; private String appId;
@Column(nullable = false) @Column(nullable = false)
private String name; private String name;
...@@ -37,11 +37,11 @@ public class App implements Serializable { ...@@ -37,11 +37,11 @@ public class App implements Serializable {
private Date lastUpdatedTimestamp; private Date lastUpdatedTimestamp;
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
......
...@@ -9,7 +9,7 @@ import java.util.List; ...@@ -9,7 +9,7 @@ import java.util.List;
public class AppConfigVO { public class AppConfigVO {
private long appId; private String appId;
private Env env; private Env env;
...@@ -46,7 +46,7 @@ public class AppConfigVO { ...@@ -46,7 +46,7 @@ public class AppConfigVO {
} }
public static AppConfigVO newInstance(long appId, long versionId) { public static AppConfigVO newInstance(String appId, long versionId) {
AppConfigVO instance = new AppConfigVO(); AppConfigVO instance = new AppConfigVO();
instance.setAppId(appId); instance.setAppId(appId);
instance.setVersionId(versionId); instance.setVersionId(versionId);
...@@ -62,18 +62,18 @@ public class AppConfigVO { ...@@ -62,18 +62,18 @@ public class AppConfigVO {
public static class OverrideAppConfig { public static class OverrideAppConfig {
private long appId; private String appId;
private List<ConfigItemDTO> configs; private List<ConfigItemDTO> configs;
public OverrideAppConfig() { public OverrideAppConfig() {
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
...@@ -120,11 +120,11 @@ public class AppConfigVO { ...@@ -120,11 +120,11 @@ public class AppConfigVO {
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
......
...@@ -26,7 +26,7 @@ public class Privilege implements Serializable { ...@@ -26,7 +26,7 @@ public class Privilege implements Serializable {
private String privilType; private String privilType;
@Column @Column
private long appId; private String appId;
public long getId() { public long getId() {
return id; return id;
...@@ -52,11 +52,11 @@ public class Privilege implements Serializable { ...@@ -52,11 +52,11 @@ public class Privilege implements Serializable {
this.privilType = privilType; this.privilType = privilType;
} }
public long getAppId() { public String getAppId() {
return appId; return appId;
} }
public void setAppId(long appId) { public void setAppId(String appId) {
this.appId = appId; this.appId = appId;
} }
} }
...@@ -10,5 +10,5 @@ public interface AppRepository extends PagingAndSortingRepository<App, String> { ...@@ -10,5 +10,5 @@ public interface AppRepository extends PagingAndSortingRepository<App, String> {
Page<App> findAll(Pageable pageable); Page<App> findAll(Pageable pageable);
App findByAppId(long appId); App findByAppId(String appId);
} }
...@@ -8,9 +8,9 @@ import java.util.List; ...@@ -8,9 +8,9 @@ import java.util.List;
public interface PrivilegeRepository extends PagingAndSortingRepository<Privilege, Long> { public interface PrivilegeRepository extends PagingAndSortingRepository<Privilege, Long> {
List<Privilege> findByAppId(long appId); List<Privilege> findByAppId(String appId);
List<Privilege> findByAppIdAndPrivilType(long appId, String privilType); List<Privilege> findByAppIdAndPrivilType(String appId, String privilType);
Privilege findByAppIdAndNameAndPrivilType(long appId, String name, String privilType); Privilege findByAppIdAndNameAndPrivilType(String appId, String name, String privilType);
} }
...@@ -16,7 +16,7 @@ public class AppService { ...@@ -16,7 +16,7 @@ public class AppService {
@Autowired @Autowired
private AppRepository appRepository; private AppRepository appRepository;
public App detail(long appId) { public App detail(String appId) {
return appRepository.findByAppId(appId); return appRepository.findByAppId(appId);
} }
......
...@@ -24,6 +24,7 @@ import com.ctrip.apollo.portal.constants.PortalConstants; ...@@ -24,6 +24,7 @@ import com.ctrip.apollo.portal.constants.PortalConstants;
import com.ctrip.apollo.portal.entity.AppConfigVO; import com.ctrip.apollo.portal.entity.AppConfigVO;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Strings;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
@Service @Service
...@@ -40,8 +41,9 @@ public class ConfigService { ...@@ -40,8 +41,9 @@ public class ConfigService {
private ObjectMapper objectMapper = new ObjectMapper(); private ObjectMapper objectMapper = new ObjectMapper();
public AppConfigVO loadReleaseConfig(Env env, long appId, long versionId) { public AppConfigVO loadReleaseConfig(Env env, String appId, long versionId) {
if (appId <= 0 || versionId <= 0) {
if (Strings.isNullOrEmpty(appId) || versionId <= 0) {
return null; return null;
} }
...@@ -78,18 +80,18 @@ public class ConfigService { ...@@ -78,18 +80,18 @@ public class ConfigService {
return version.getReleaseId(); return version.getReleaseId();
} }
private void collectDefaultClusterConfigs(long appId, ReleaseSnapshotDTO snapShot, private void collectDefaultClusterConfigs(String appId, ReleaseSnapshotDTO snapShot,
AppConfigVO appConfigVO) { AppConfigVO appConfigVO) {
Map<Long, List<ConfigItemDTO>> groupedConfigs = groupConfigsByApp(snapShot.getConfigurations()); Map<String, List<ConfigItemDTO>> groupedConfigs = groupConfigsByApp(snapShot.getConfigurations());
List<AppConfigVO.OverrideAppConfig> overrideAppConfigs = appConfigVO.getOverrideAppConfigs(); List<AppConfigVO.OverrideAppConfig> overrideAppConfigs = appConfigVO.getOverrideAppConfigs();
for (Map.Entry<Long, List<ConfigItemDTO>> entry : groupedConfigs.entrySet()) { for (Map.Entry<String, List<ConfigItemDTO>> entry : groupedConfigs.entrySet()) {
long configAppId = entry.getKey(); String configAppId = entry.getKey();
List<ConfigItemDTO> kvs = entry.getValue(); List<ConfigItemDTO> kvs = entry.getValue();
if (configAppId == appId) { if (configAppId.equals(appId)) {
appConfigVO.setDefaultClusterConfigs(kvs); appConfigVO.setDefaultClusterConfigs(kvs);
} else { } else {
...@@ -105,12 +107,12 @@ public class ConfigService { ...@@ -105,12 +107,12 @@ public class ConfigService {
/** /**
* appId -> List<KV> * appId -> List<KV>
*/ */
private Map<Long, List<ConfigItemDTO>> groupConfigsByApp(String configJson) { private Map<String, List<ConfigItemDTO>> groupConfigsByApp(String configJson) {
if (configJson == null || "".equals(configJson)) { if (configJson == null || "".equals(configJson)) {
return Maps.newHashMap(); return Maps.newHashMap();
} }
Map<Long, List<ConfigItemDTO>> appIdMapKVs = new HashMap<>(); Map<String, List<ConfigItemDTO>> appIdMapKVs = new HashMap<>();
String key; String key;
Object value; Object value;
...@@ -124,7 +126,7 @@ public class ConfigService { ...@@ -124,7 +126,7 @@ public class ConfigService {
key = entry.getKey(); key = entry.getKey();
value = entry.getValue(); value = entry.getValue();
Long appId = getAppIdFromKey(key); String appId = getAppIdFromKey(key);
List<ConfigItemDTO> kvs = appIdMapKVs.get(appId); List<ConfigItemDTO> kvs = appIdMapKVs.get(appId);
if (kvs == null) { if (kvs == null) {
kvs = new LinkedList<>(); kvs = new LinkedList<>();
...@@ -137,11 +139,11 @@ public class ConfigService { ...@@ -137,11 +139,11 @@ public class ConfigService {
} }
private Long getAppIdFromKey(String key) { private String getAppIdFromKey(String key) {
return Long.valueOf(key.substring(0, key.indexOf("."))); return key.substring(0, key.indexOf("."));
} }
private void collectSpecialClusterConfigs(long appId, ReleaseSnapshotDTO snapShot, private void collectSpecialClusterConfigs(String appId, ReleaseSnapshotDTO snapShot,
AppConfigVO appConfigVO) { AppConfigVO appConfigVO) {
List<AppConfigVO.OverrideClusterConfig> overrideClusterConfigs = List<AppConfigVO.OverrideClusterConfig> overrideClusterConfigs =
appConfigVO.getOverrideClusterConfigs(); appConfigVO.getOverrideClusterConfigs();
...@@ -153,8 +155,8 @@ public class ConfigService { ...@@ -153,8 +155,8 @@ public class ConfigService {
overrideClusterConfigs.add(overrideClusterConfig); overrideClusterConfigs.add(overrideClusterConfig);
} }
public AppConfigVO loadLatestConfig(Env env, long appId) { public AppConfigVO loadLatestConfig(Env env, String appId) {
if (appId <= 0) { if (Strings.isNullOrEmpty(appId)) {
return null; return null;
} }
...@@ -173,7 +175,7 @@ public class ConfigService { ...@@ -173,7 +175,7 @@ public class ConfigService {
return buildAPPConfigVO(appId, Arrays.asList(configItems)); return buildAPPConfigVO(appId, Arrays.asList(configItems));
} }
private AppConfigVO buildAPPConfigVO(long appId, List<ConfigItemDTO> configItems) { private AppConfigVO buildAPPConfigVO(String appId, List<ConfigItemDTO> configItems) {
if (configItems == null || configItems.size() == 0) { if (configItems == null || configItems.size() == 0) {
return null; return null;
} }
...@@ -206,7 +208,7 @@ public class ConfigService { ...@@ -206,7 +208,7 @@ public class ConfigService {
private void groupConfigByAppAndEnrichDTO(Map<String, List<ConfigItemDTO>> groupedClusterConfigs, private void groupConfigByAppAndEnrichDTO(Map<String, List<ConfigItemDTO>> groupedClusterConfigs,
AppConfigVO appConfigVO) { AppConfigVO appConfigVO) {
long appId = appConfigVO.getAppId(); String appId = appConfigVO.getAppId();
List<ConfigItemDTO> defaultClusterConfigs = appConfigVO.getDefaultClusterConfigs(); List<ConfigItemDTO> defaultClusterConfigs = appConfigVO.getDefaultClusterConfigs();
...@@ -232,14 +234,14 @@ public class ConfigService { ...@@ -232,14 +234,14 @@ public class ConfigService {
} }
} }
private void collectDefaultClusterConfigs(long appId, List<ConfigItemDTO> clusterConfigs, private void collectDefaultClusterConfigs(String appId, List<ConfigItemDTO> clusterConfigs,
List<ConfigItemDTO> defaultClusterConfigs, List<ConfigItemDTO> defaultClusterConfigs,
List<AppConfigVO.OverrideAppConfig> overrideAppConfigs) { List<AppConfigVO.OverrideAppConfig> overrideAppConfigs) {
Map<Long, AppConfigVO.OverrideAppConfig> appIdMapOverrideAppConfig = null; Map<String, AppConfigVO.OverrideAppConfig> appIdMapOverrideAppConfig = null;
for (ConfigItemDTO config : clusterConfigs) { for (ConfigItemDTO config : clusterConfigs) {
long targetAppId = config.getAppId(); String targetAppId = config.getAppId();
if (appId == targetAppId) {// app self's configs if (appId == targetAppId) {// app self's configs
defaultClusterConfigs.add(config); defaultClusterConfigs.add(config);
} else {// override other app configs } else {// override other app configs
......
...@@ -19,7 +19,7 @@ public class PrivilegeService { ...@@ -19,7 +19,7 @@ public class PrivilegeService {
@Autowired @Autowired
private PrivilegeRepository privilRepo; private PrivilegeRepository privilRepo;
public Privilege addPrivilege(long appId, String name, PrivilType privilType) { public Privilege addPrivilege(String appId, String name, PrivilType privilType) {
Privilege privil = privilRepo.findByAppIdAndNameAndPrivilType(appId, name, privilType.name()); Privilege privil = privilRepo.findByAppIdAndNameAndPrivilType(appId, name, privilType.name());
if (privil == null) { if (privil == null) {
privil = new Privilege(); privil = new Privilege();
...@@ -31,16 +31,16 @@ public class PrivilegeService { ...@@ -31,16 +31,16 @@ public class PrivilegeService {
return privil; return privil;
} }
public boolean hasPrivilege(long appId, String name, PrivilType privilType) { public boolean hasPrivilege(String appId, String name, PrivilType privilType) {
Privilege privil = privilRepo.findByAppIdAndNameAndPrivilType(appId, name, privilType.name()); Privilege privil = privilRepo.findByAppIdAndNameAndPrivilType(appId, name, privilType.name());
return (privil != null) ? true : false; return (privil != null) ? true : false;
} }
public List<Privilege> listPrivileges(long appId) { public List<Privilege> listPrivileges(String appId) {
return privilRepo.findByAppId(appId); return privilRepo.findByAppId(appId);
} }
public void removePrivilege(long appId, String name, PrivilType privilType) { public void removePrivilege(String appId, String name, PrivilType privilType) {
Privilege privil = privilRepo.findByAppIdAndNameAndPrivilType(appId, name, privilType.name()); Privilege privil = privilRepo.findByAppIdAndNameAndPrivilType(appId, name, privilType.name());
if (privil == null) { if (privil == null) {
throw new NotFoundException(); throw new NotFoundException();
......
...@@ -17,7 +17,7 @@ public class VersionService { ...@@ -17,7 +17,7 @@ public class VersionService {
@Autowired @Autowired
private AdminServiceAPI.VersionAPI versionAPI; private AdminServiceAPI.VersionAPI versionAPI;
public List<VersionDTO> findVersionsByApp(Apollo.Env env, long appId) { public List<VersionDTO> findVersionsByApp(Apollo.Env env, String appId) {
VersionDTO[] versions = versionAPI.getVersionsByApp(env, appId); VersionDTO[] versions = versionAPI.getVersionsByApp(env, appId);
if (versions == null || versions.length == 0){ if (versions == null || versions.length == 0){
......
...@@ -32,7 +32,7 @@ public class AppControllerTest extends AbstractPortalTest { ...@@ -32,7 +32,7 @@ public class AppControllerTest extends AbstractPortalTest {
@Test @Test
public void testCreate() throws URISyntaxException { public void testCreate() throws URISyntaxException {
App newApp = new App(); App newApp = new App();
newApp.setAppId(System.currentTimeMillis()); newApp.setAppId(String.valueOf(System.currentTimeMillis()));
newApp.setName("new app " + System.currentTimeMillis()); newApp.setName("new app " + System.currentTimeMillis());
newApp.setOwner("owner " + System.currentTimeMillis()); newApp.setOwner("owner " + System.currentTimeMillis());
...@@ -51,7 +51,7 @@ public class AppControllerTest extends AbstractPortalTest { ...@@ -51,7 +51,7 @@ public class AppControllerTest extends AbstractPortalTest {
@Test @Test
public void testList() throws URISyntaxException { public void testList() throws URISyntaxException {
App newApp = new App(); App newApp = new App();
newApp.setAppId(System.currentTimeMillis()); newApp.setAppId(String.valueOf(System.currentTimeMillis()));
newApp.setName("new app " + System.currentTimeMillis()); newApp.setName("new app " + System.currentTimeMillis());
newApp.setOwner("owner " + System.currentTimeMillis()); newApp.setOwner("owner " + System.currentTimeMillis());
appRepository.save(newApp); appRepository.save(newApp);
...@@ -66,7 +66,7 @@ public class AppControllerTest extends AbstractPortalTest { ...@@ -66,7 +66,7 @@ public class AppControllerTest extends AbstractPortalTest {
@Test @Test
public void testListOutOfRange() throws URISyntaxException { public void testListOutOfRange() throws URISyntaxException {
App newApp = new App(); App newApp = new App();
newApp.setAppId(System.currentTimeMillis()); newApp.setAppId(String.valueOf(System.currentTimeMillis()));
newApp.setName("new app " + System.currentTimeMillis()); newApp.setName("new app " + System.currentTimeMillis());
newApp.setOwner("owner " + System.currentTimeMillis()); newApp.setOwner("owner " + System.currentTimeMillis());
appRepository.save(newApp); appRepository.save(newApp);
......
...@@ -18,7 +18,7 @@ public class AppRepositoryTest extends AbstractPortalTest { ...@@ -18,7 +18,7 @@ public class AppRepositoryTest extends AbstractPortalTest {
Assert.assertEquals(0, repository.count()); Assert.assertEquals(0, repository.count());
App ramdomApp = new App(); App ramdomApp = new App();
ramdomApp.setAppId(System.currentTimeMillis()); ramdomApp.setAppId(String.valueOf(System.currentTimeMillis()));
ramdomApp.setName("new app " + System.currentTimeMillis()); ramdomApp.setName("new app " + System.currentTimeMillis());
ramdomApp.setOwner("owner " + System.currentTimeMillis()); ramdomApp.setOwner("owner " + System.currentTimeMillis());
repository.save(ramdomApp); repository.save(ramdomApp);
......
...@@ -3,7 +3,6 @@ package com.ctrip.apollo.portal.service; ...@@ -3,7 +3,6 @@ package com.ctrip.apollo.portal.service;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -63,7 +62,7 @@ public class ConfigServiceTest { ...@@ -63,7 +62,7 @@ public class ConfigServiceTest {
@Test @Test
public void testLoadReleaseConfig() { public void testLoadReleaseConfig() {
long appId = 6666; String appId = "6666";
long versionId = 100; long versionId = 100;
long releaseId = 11111; long releaseId = 11111;
...@@ -84,7 +83,7 @@ public class ConfigServiceTest { ...@@ -84,7 +83,7 @@ public class ConfigServiceTest {
@Test @Test
public void testLoadReleaseConfigOnlyDefaultConfigs() { public void testLoadReleaseConfigOnlyDefaultConfigs() {
long appId = 6666; String appId = "6666";
long versionId = 100; long versionId = 100;
long releaseId = 11111; long releaseId = 11111;
...@@ -107,7 +106,7 @@ public class ConfigServiceTest { ...@@ -107,7 +106,7 @@ public class ConfigServiceTest {
@Test @Test
public void testLoadReleaseConfigDefaultConfigsAndOverrideApp() { public void testLoadReleaseConfigDefaultConfigsAndOverrideApp() {
long appId = 6666; String appId = "6666";
long versionId = 100; long versionId = 100;
long releaseId = 11111; long releaseId = 11111;
VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId); VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
...@@ -129,7 +128,7 @@ public class ConfigServiceTest { ...@@ -129,7 +128,7 @@ public class ConfigServiceTest {
@Test @Test
public void testLoadReleaseConfigDefaultConfigsAndOverrideCluster() { public void testLoadReleaseConfigDefaultConfigsAndOverrideCluster() {
long appId = 6666; String appId = "6666";
long versionId = 100; long versionId = 100;
long releaseId = 11111; long releaseId = 11111;
VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId); VersionDTO someVersion = assembleVersion(appId, "1.0", releaseId);
...@@ -153,7 +152,7 @@ public class ConfigServiceTest { ...@@ -153,7 +152,7 @@ public class ConfigServiceTest {
@Test @Test
public void testLoadLastestConfig() { public void testLoadLastestConfig() {
long appId = 6666; String appId = "6666";
ClusterDTO[] someClusters = assembleClusters(); ClusterDTO[] someClusters = assembleClusters();
ConfigItemDTO[] someConfigItem = assembleConfigItems(); ConfigItemDTO[] someConfigItem = assembleConfigItems();
...@@ -163,14 +162,14 @@ public class ConfigServiceTest { ...@@ -163,14 +162,14 @@ public class ConfigServiceTest {
AppConfigVO appConfigVO = configService.loadLatestConfig(Env.DEV, appId); AppConfigVO appConfigVO = configService.loadLatestConfig(Env.DEV, appId);
assertEquals(appConfigVO.getAppId(), 6666); assertEquals(appConfigVO.getAppId(), "6666");
assertEquals(appConfigVO.getVersionId(), PortalConstants.LASTEST_VERSION_ID); assertEquals(appConfigVO.getVersionId(), PortalConstants.LASTEST_VERSION_ID);
assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 3); assertEquals(appConfigVO.getDefaultClusterConfigs().size(), 3);
assertEquals(appConfigVO.getOverrideAppConfigs().size(), 1); assertEquals(appConfigVO.getOverrideAppConfigs().size(), 1);
assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 1); assertEquals(appConfigVO.getOverrideClusterConfigs().size(), 1);
} }
private VersionDTO assembleVersion(long appId, String versionName, long releaseId) { private VersionDTO assembleVersion(String appId, String versionName, long releaseId) {
VersionDTO version = new VersionDTO(); VersionDTO version = new VersionDTO();
version.setAppId(appId); version.setAppId(appId);
version.setName(versionName); version.setName(versionName);
...@@ -198,12 +197,12 @@ public class ConfigServiceTest { ...@@ -198,12 +197,12 @@ public class ConfigServiceTest {
private ClusterDTO[] assembleClusters() { private ClusterDTO[] assembleClusters() {
ClusterDTO[] clusters = new ClusterDTO[2]; ClusterDTO[] clusters = new ClusterDTO[2];
clusters[0] = assembleCluster(100, 6666, Constants.DEFAULT_CLUSTER_NAME); clusters[0] = assembleCluster(100, "6666", Constants.DEFAULT_CLUSTER_NAME);
clusters[1] = assembleCluster(101, 6666, "cluster1"); clusters[1] = assembleCluster(101, "6666", "cluster1");
return clusters; return clusters;
} }
private ClusterDTO assembleCluster(long id, long appId, String name) { private ClusterDTO assembleCluster(long id, String appId, String name) {
ClusterDTO cluster = new ClusterDTO(); ClusterDTO cluster = new ClusterDTO();
cluster.setAppId(appId); cluster.setAppId(appId);
cluster.setId(id); cluster.setId(id);
...@@ -213,19 +212,15 @@ public class ConfigServiceTest { ...@@ -213,19 +212,15 @@ public class ConfigServiceTest {
private ConfigItemDTO[] assembleConfigItems() { private ConfigItemDTO[] assembleConfigItems() {
ConfigItemDTO[] configItems = new ConfigItemDTO[5]; ConfigItemDTO[] configItems = new ConfigItemDTO[5];
configItems[0] = configItems[0] = assembleConfigItem(100, Constants.DEFAULT_CLUSTER_NAME, "6666", "6666.k1", "6666.v1");
assembleConfigItem(100, Constants.DEFAULT_CLUSTER_NAME, 6666, "6666.k1", "6666.v1"); configItems[1] = assembleConfigItem(100, Constants.DEFAULT_CLUSTER_NAME, "6666", "6666.k2", "6666.v2");
configItems[1] = configItems[2] = assembleConfigItem(100, Constants.DEFAULT_CLUSTER_NAME, "6666", "6666.k3", "6666.v3");
assembleConfigItem(100, Constants.DEFAULT_CLUSTER_NAME, 6666, "6666.k2", "6666.v2"); configItems[3] = assembleConfigItem(100, Constants.DEFAULT_CLUSTER_NAME, "5555", "5555.k1", "5555.v1");
configItems[2] = configItems[4] = assembleConfigItem(101, "cluster1", "6666", "6666.k1", "6666.v1");
assembleConfigItem(100, Constants.DEFAULT_CLUSTER_NAME, 6666, "6666.k3", "6666.v3");
configItems[3] =
assembleConfigItem(100, Constants.DEFAULT_CLUSTER_NAME, 5555, "5555.k1", "5555.v1");
configItems[4] = assembleConfigItem(101, "cluster1", 6666, "6666.k1", "6666.v1");
return configItems; return configItems;
} }
private ConfigItemDTO assembleConfigItem(long clusterId, String clusterName, int appId, private ConfigItemDTO assembleConfigItem(long clusterId, String clusterName, String appId,
String key, String value) { String key, String value) {
ConfigItemDTO configItem = new ConfigItemDTO(); ConfigItemDTO configItem = new ConfigItemDTO();
configItem.setClusterName(clusterName); configItem.setClusterName(clusterName);
......
...@@ -21,7 +21,7 @@ public class PrivilegeServiceTest extends AbstractPortalTest { ...@@ -21,7 +21,7 @@ public class PrivilegeServiceTest extends AbstractPortalTest {
@Test @Test
public void testAddAndRemovePrivilege() { public void testAddAndRemovePrivilege() {
App newApp = new App(); App newApp = new App();
newApp.setAppId((System.currentTimeMillis())); newApp.setAppId(String.valueOf(System.currentTimeMillis()));
newApp.setName("new app " + System.currentTimeMillis()); newApp.setName("new app " + System.currentTimeMillis());
newApp.setOwner("owner " + System.currentTimeMillis()); newApp.setOwner("owner " + System.currentTimeMillis());
appService.save(newApp); appService.save(newApp);
...@@ -42,7 +42,7 @@ public class PrivilegeServiceTest extends AbstractPortalTest { ...@@ -42,7 +42,7 @@ public class PrivilegeServiceTest extends AbstractPortalTest {
@Test @Test
public void testCheckPrivilege() { public void testCheckPrivilege() {
App newApp = new App(); App newApp = new App();
newApp.setAppId((System.currentTimeMillis())); newApp.setAppId(String.valueOf(System.currentTimeMillis()));
newApp.setName("new app " + System.currentTimeMillis()); newApp.setName("new app " + System.currentTimeMillis());
newApp.setOwner("owner " + System.currentTimeMillis()); newApp.setOwner("owner " + System.currentTimeMillis());
appService.save(newApp); appService.save(newApp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment