Skip to content

Commit

Permalink
feat(apollo-biz): Additional test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
klboke committed Dec 14, 2022
1 parent deeadf3 commit 99fc20b
Showing 1 changed file with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright 2022 Apollo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.ctrip.framework.apollo.biz.service;

import com.ctrip.framework.apollo.biz.AbstractIntegrationTest;
import com.ctrip.framework.apollo.biz.entity.ServerConfig;
import java.util.List;

import static org.assertj.core.api.Assertions.*;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

/**
* @author kl (http://kailing.pub)
* @since 2022/12/14
*/
public class ServerConfigServiceTest extends AbstractIntegrationTest {

@Autowired
private ServerConfigService serverConfigService;

@Test
public void findAll() {
List<ServerConfig> serverConfigs = serverConfigService.findAll();
assertThat(serverConfigs).isNotNull();
assertThat(serverConfigs.size()).isGreaterThanOrEqualTo(0);
}

@Test
public void createOrUpdateConfig() {
ServerConfig serverConfig = new ServerConfig();
serverConfig.setKey("name");
serverConfig.setValue("kl");
serverConfigService.createOrUpdateConfig(serverConfig);

List<ServerConfig> serverConfigs = serverConfigService.findAll();
assertThat(serverConfigs).isNotNull();
assertThat(serverConfigs.get(0).getValue()).isEqualTo("kl");
assertThat(serverConfigs.get(0).getCluster()).isEqualTo("default");
assertThat(serverConfigs.get(0).getKey()).isEqualTo("name");


serverConfig.setValue("kl2");
serverConfigService.createOrUpdateConfig(serverConfig);

serverConfigs = serverConfigService.findAll();
assertThat(serverConfigs).isNotNull();
assertThat(serverConfigs.size()).isEqualTo(1);
assertThat(serverConfigs.get(0).getValue()).isEqualTo("kl2");
assertThat(serverConfigs.get(0).getKey()).isEqualTo("name");

serverConfig = new ServerConfig();
serverConfig.setKey("name2");
serverConfig.setValue("kl2");
serverConfigService.createOrUpdateConfig(serverConfig);

serverConfigs = serverConfigService.findAll();
assertThat(serverConfigs).isNotNull();
assertThat(serverConfigs.size()).isEqualTo(2);
}
}

0 comments on commit 99fc20b

Please sign in to comment.