Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Schneider committed Jul 19, 2018
1 parent 5632cd4 commit 8217454
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,30 @@ default String retentionPolicy() {
return get(prefix() + ".retentionPolicy");
}

/**
* @return Time period for which influx should retain data in the current database (e.g. 2h, 52w).
*/
@Nullable
default String retentionDuration(){
return get(prefix() + ".retentionDuration");
}
/**
* @return Time period for which influx should retain data in the current database (e.g. 2h, 52w).
*/
@Nullable
default String retentionDuration() {
return get(prefix() + ".retentionDuration");
}

/**
* @return How many copies of the data are stored in the cluster. Must be 1 for a single node instance.
*/
@Nullable
default Integer retentionReplicationFactor(){
String v = get(prefix() + ".retentionReplicationFactor");
return v == null ? null : Integer.parseInt(v);
}
/**
* @return How many copies of the data are stored in the cluster. Must be 1 for a single node instance.
*/
@Nullable
default Integer retentionReplicationFactor() {
String v = get(prefix() + ".retentionReplicationFactor");
return v == null ? null : Integer.parseInt(v);
}

/**
* @return The time range covered by a shard group (e.g. 2h, 52w).
*/
@Nullable
default String retentionShardDuration(){
return get(prefix() + ".retentionShardDuration");
}
* @return The time range covered by a shard group (e.g. 2h, 52w).
*/
@Nullable
default String retentionShardDuration() {
return get(prefix() + ".retentionShardDuration");
}


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,52 @@
*/
package io.micrometer.influx;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

class CreateDatabaseQueryBuilderTest {

private static String TEST_DB_NAME = "dummy_database_0";
private static String TEST_DB_NAME = "dummy_database_0";

/**
* Class Parameters:
*
* - database name
* - retention clauses
*
* Class Criteria
* - database name is not null -> true false
* - retention clauses -> no one all
*/
private final CreateDatabaseQueryBuilder createDatabaseQueryBuilder = new CreateDatabaseQueryBuilder(TEST_DB_NAME);
/**
* Class Parameters:
* <p>
* - database name
* - retention clauses
* <p>
* Class Criteria
* - database name is not null -> true false
* - retention clauses -> no one all
*/
private final CreateDatabaseQueryBuilder createDatabaseQueryBuilder = new CreateDatabaseQueryBuilder(TEST_DB_NAME);

@Test
void noEmptyDatabaseName() {
assertThrows(IllegalArgumentException.class, () -> new CreateDatabaseQueryBuilder(null));
}
@Test
void noEmptyDatabaseName() {
assertThrows(IllegalArgumentException.class, () -> new CreateDatabaseQueryBuilder(null));
}

@Test
void noRetentionPolicy() {
String query = createDatabaseQueryBuilder.build();
assertEquals("CREATE DATABASE dummy_database_0", query);
}
@Test
void noRetentionPolicy() {
String query = createDatabaseQueryBuilder.build();
assertEquals("CREATE DATABASE dummy_database_0", query);
}

@Test
void oneClauseInRetentionPolicy() {
String query = createDatabaseQueryBuilder.setRetentionPolicyName("dummy_policy").build();
assertEquals("CREATE DATABASE dummy_database_0 WITH NAME dummy_policy", query);
}
@Test
void oneClauseInRetentionPolicy() {
String query = createDatabaseQueryBuilder.setRetentionPolicyName("dummy_policy").build();
assertEquals("CREATE DATABASE dummy_database_0 WITH NAME dummy_policy", query);
}

@Test
void allClausesInRetentionPolicy() {
String query = createDatabaseQueryBuilder.setRetentionPolicyName("dummy_policy")
.setRetentionDuration("2d")
.setRetentionReplicationFactor(1)
.setRetentionShardDuration("3")
.build();
assertEquals("CREATE DATABASE dummy_database_0 WITH DURATION 2d REPLICATION 1 SHARD DURATION 3 NAME dummy_policy", query);
}
@Test
void allClausesInRetentionPolicy() {
String query = createDatabaseQueryBuilder.setRetentionPolicyName("dummy_policy")
.setRetentionDuration("2d")
.setRetentionReplicationFactor(1)
.setRetentionShardDuration("3")
.build();
assertEquals("CREATE DATABASE dummy_database_0 WITH DURATION 2d REPLICATION 1 SHARD DURATION 3 NAME dummy_policy", query);
}

}

0 comments on commit 8217454

Please sign in to comment.