You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/07/20 03:44:58 UTC
[shardingsphere] branch master updated: remove unrelated file (#19377)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new ff9c7cb11ea remove unrelated file (#19377)
ff9c7cb11ea is described below
commit ff9c7cb11ea41a15cfafc5b1ba234ae424ccce77
Author: xuup <33...@users.noreply.github.com>
AuthorDate: Wed Jul 20 11:44:52 2022 +0800
remove unrelated file (#19377)
---
.../service/MetaDataVersionPersistServiceTest.java | 78 ++++++++++++++++++++++
1 file changed, 78 insertions(+)
diff --git a/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/MetaDataVersionPersistServiceTest.java b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/MetaDataVersionPersistServiceTest.java
new file mode 100644
index 00000000000..2208f499c45
--- /dev/null
+++ b/shardingsphere-mode/shardingsphere-mode-core/src/test/java/org/apache/shardingsphere/mode/metadata/persist/service/MetaDataVersionPersistServiceTest.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.shardingsphere.mode.metadata.persist.service;
+
+import org.apache.shardingsphere.mode.metadata.persist.node.DatabaseMetaDataNode;
+import org.apache.shardingsphere.mode.persist.PersistRepository;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public final class MetaDataVersionPersistServiceTest {
+
+ private PersistRepository repository;
+
+ private MetaDataVersionPersistService metaDataVersionPersistService;
+
+ @Before
+ public void setUp() {
+ repository = mock(PersistRepository.class);
+ when(repository.get(contains("foo_db"))).thenReturn("1");
+ metaDataVersionPersistService = new MetaDataVersionPersistService(repository);
+ }
+
+ @Test
+ public void assertGetActiveVersion() {
+ assertTrue(metaDataVersionPersistService.getActiveVersion("foo_db").isPresent());
+ verify(repository).get(DatabaseMetaDataNode.getActiveVersionPath("foo_db"));
+ }
+
+ @Test
+ public void assertIsActiveVersion() {
+ assertTrue(metaDataVersionPersistService.isActiveVersion("foo_db", "1"));
+ }
+
+ @Test
+ public void assertCreateNewVersion() {
+ assertFalse(metaDataVersionPersistService.createNewVersion("new_db").isPresent());
+ assertThat(metaDataVersionPersistService.createNewVersion("foo_db").get(), equalTo("2"));
+ verify(repository, times(2)).persist(contains("foo_db"), anyString());
+ }
+
+ @Test
+ public void assertPersistActiveVersion() {
+ metaDataVersionPersistService.persistActiveVersion("foo_db", "2");
+ verify(repository).persist(DatabaseMetaDataNode.getActiveVersionPath("foo_db"), "2");
+ }
+
+ @Test
+ public void assertDeleteVersion() {
+ metaDataVersionPersistService.deleteVersion("foo_db", "1");
+ verify(repository).delete(DatabaseMetaDataNode.getDatabaseVersionPath("foo_db", "1"));
+ }
+}