-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
254 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
cassdio-core/src/test/java/kr/hakdang/cassdio/core/domain/cluster/ClusterConnectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package kr.hakdang.cassdio.core.domain.cluster; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EmptySource; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
/** | ||
* ClusterConnectionTest | ||
* | ||
* @author Seungho Kang ([email protected]) | ||
* @version 1.0.0 | ||
* @since 2024. 07. 07. | ||
*/ | ||
class ClusterConnectionTest { | ||
|
||
@Test | ||
void anonymous_cluster_connection() { | ||
// when | ||
ClusterConnection connection = ClusterConnection.builder() | ||
.contactPoints("127.0.0.1") | ||
.port(29042) | ||
.localDatacenter("dc1") | ||
.build(); | ||
|
||
// then | ||
assertThat(connection.isAuthCredentials()).isFalse(); | ||
assertThat(connection.getContactPoints()).isEqualTo("127.0.0.1"); | ||
assertThat(connection.getPort()).isEqualTo(29042); | ||
assertThat(connection.getUsername()).isEqualTo(null); | ||
assertThat(connection.getPassword()).isEqualTo(null); | ||
assertThat(connection.getLocalDatacenter()).isEqualTo("dc1"); | ||
} | ||
|
||
@Test | ||
void authenticated_cluster_connection() { | ||
// when | ||
ClusterConnection connection = ClusterConnection.builder() | ||
.contactPoints("127.0.0.1") | ||
.port(29042) | ||
.localDatacenter("dc1") | ||
.username("will") | ||
.password("will-password") | ||
.build(); | ||
|
||
// then | ||
assertThat(connection.isAuthCredentials()).isTrue(); | ||
assertThat(connection.getContactPoints()).isEqualTo("127.0.0.1"); | ||
assertThat(connection.getPort()).isEqualTo(29042); | ||
assertThat(connection.getUsername()).isEqualTo("will"); | ||
assertThat(connection.getPassword()).isEqualTo("will-password"); | ||
assertThat(connection.getLocalDatacenter()).isEqualTo("dc1"); | ||
} | ||
|
||
|
||
@EmptySource | ||
@ParameterizedTest | ||
void contactPoints_is_required(String contactPoints) { | ||
// when & then | ||
assertThatThrownBy(() -> | ||
ClusterConnection.builder() | ||
.contactPoints(contactPoints) | ||
.port(29042) | ||
.localDatacenter("dc1") | ||
.build() | ||
).isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@ValueSource(ints = { | ||
0, | ||
-1 | ||
}) | ||
@ParameterizedTest | ||
void port_should_be_positive(int port) { | ||
// when & then | ||
assertThatThrownBy(() -> | ||
ClusterConnection.builder() | ||
.contactPoints("127.0.0.1") | ||
.port(port) | ||
.localDatacenter("dc1") | ||
.build() | ||
).isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@EmptySource | ||
@ParameterizedTest | ||
void local_datacenter_is_required(String localDatacenter) { | ||
// when & then | ||
assertThatThrownBy(() -> | ||
ClusterConnection.builder() | ||
.contactPoints("127.0.0.1") | ||
.port(9042) | ||
.localDatacenter(localDatacenter) | ||
.build() | ||
).isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...est/java/kr/hakdang/cassdio/core/domain/cluster/keyspace/table/column/ColumnKindTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package kr.hakdang.cassdio.core.domain.cluster.keyspace.table.column; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* ColumnKindTest | ||
* | ||
* @author Seungho Kang ([email protected]) | ||
* @version 1.0.0 | ||
* @since 2024. 07. 07. | ||
*/ | ||
class ColumnKindTest { | ||
|
||
@Test | ||
void find_column_kind() { | ||
assertThat(ColumnKind.findByCode("partition_key")).isEqualTo(ColumnKind.PARTITION_KEY); | ||
assertThat(ColumnKind.findByCode("clustering")).isEqualTo(ColumnKind.CLUSTERING); | ||
assertThat(ColumnKind.findByCode("regular")).isEqualTo(ColumnKind.REGULAR); | ||
} | ||
|
||
@Test | ||
void unknown_column_kind() { | ||
assertThat(ColumnKind.findByCode("blabla")).isEqualTo(ColumnKind.UNKNOWN); | ||
} | ||
|
||
} |