Skip to content

Commit

Permalink
Make accountId type to String
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertojrequena committed Mar 14, 2020
1 parent deb44fb commit d5c3951
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 19 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The rest of the operations return dummy responses when invoked.
For starting an embedded server the `BonsaiSnsServerBuilder` can be used
```
BonsaiSnsServer server = new BonsaiSnsServer.Builder()
.withAccountId(123L)
.withAccountId("123")
.withPort(9999)
.withRegion("someRegion")
.withSqsEndpoint("http://localhost:9324")
Expand All @@ -40,13 +40,13 @@ server.stop();

### Stand-alone server

Download the [jar](https://repo1.maven.org/maven2/io/github/gilbertojrequena/bonsai-sns/0.1.6/bonsai-sns-0.1.6.jar) and execute it
Download the [jar](https://repo1.maven.org/maven2/io/github/gilbertojrequena/bonsai-sns/0.1.7/bonsai-sns-0.1.7.jar) and execute it

`java -jar bonsai-sns-0.1.6.jar port=9494 region=region accountId=987654321 sqsEndpoint=http://localhost:9432 sqsAccessKey=foo sqsSecretKey=bar`
`java -jar bonsai-sns-0.1.7.jar port=9494 region=region accountId=987654321 sqsEndpoint=http://localhost:9432 sqsAccessKey=foo sqsSecretKey=bar`

or

`java -Dconfig.file=bonsai-sns.conf -jar bonsai-sns-0.1.6.jar`
`java -Dconfig.file=bonsai-sns.conf -jar bonsai-sns-0.1.7.jar`

### Environment configuration
bonsai-sns uses [Typesafe Config](https://github.com/lightbend/config) for loading its configuration, topics and subscriptions can be created on startup by providing an `application.conf`
Expand All @@ -57,7 +57,7 @@ configuration file
bonsai-sns {
port = 7979
region = "region"
accountId = 123456789
accountId = "123456789"
sqsEndpoint = "http://localhost:9324"
sqsAccessKey = "foo"
sqsSecretKey = "bar"
Expand Down Expand Up @@ -103,7 +103,7 @@ Environment configuration can also be done using the `BonsaiSnsServerBuilder` an

```
BonsaiSnsServer server = new BonsaiSnsServer.Builder()
.withAccountId(123L)
.withAccountId("123")
.withPort(9999)
.withRegion("someRegion")
.withSqsEndpoint("http://localhost:9324")
Expand Down Expand Up @@ -198,7 +198,7 @@ server.stop();
<dependency>
<groupId>io.github.gilbertojrequena</groupId>
<artifactId>bonsai-sns</artifactId>
<version>0.1.6</version>
<version>0.1.7</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'io.github.gilbertojrequena'
version '0.1.7-SNAPSHOT'
version '0.1.7'

sourceCompatibility = 1.8

Expand Down
2 changes: 1 addition & 1 deletion example.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bonsai-sns {
port = 7979
region = "region"
accountId = 123456789
accountId = "123456789"
sqsEndpoint = "http://localhost:9324"
sqsAccessKey = "foo"
sqsSecretKey = "bar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private fun configFromArgs(args: Array<String>): BonsaiSnsConfig {
return BonsaiSnsConfig(
port = argsMap["port"]?.toInt(),
region = argsMap["region"],
accountId = argsMap["accountId"]?.toLong(),
accountId = argsMap["accountId"],
sqsEndpoint = argsMap["sqsEndpoint"],
sqsAccessKey = argsMap["sqsAccessKey"],
sqsSecretKey = argsMap["sqsSecretKey"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.typesafe.config.ConfigFactory
public class BonsaiSnsConfig(
internal var port: Int? = null,
internal var region: String? = null,
internal var accountId: Long? = null,
internal var accountId: String? = null,
internal var bonsaiSnsEnvironment: BonsaiSnsEnvironment? = null,
internal var sqsEndpoint: String? = null,
internal var sqsAccessKey: String? = null,
Expand All @@ -16,7 +16,7 @@ public class BonsaiSnsConfig(
companion object {
private const val DEFAULT_PORT = 7979
private const val DEFAULT_REGION = "region"
private const val DEFAULT_ACCOUNT_ID = 123456789L
private const val DEFAULT_ACCOUNT_ID = "123456789"
}

init {
Expand All @@ -37,7 +37,7 @@ public class BonsaiSnsConfig(
}
if (accountId == null) {
accountId = getOrDefault(bonsaiSnsConfig, DEFAULT_ACCOUNT_ID) {
it.getLong("accountId")
it.getString("accountId")
}
}
if (sqsEndpoint.isNullOrBlank()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class BonsaiSnsServer(private val config: BonsaiSnsConfig) {
class Builder {
internal var port: Int? = null
private set
internal var accountId: Long? = null
internal var accountId: String? = null
private set
internal var region: String? = null
private set
Expand All @@ -127,7 +127,7 @@ class BonsaiSnsServer(private val config: BonsaiSnsConfig) {
private set

fun withPort(port: Int): Builder = apply { this.port = port }
fun withAccountId(accountId: Long): Builder = apply { this.accountId = accountId }
fun withAccountId(accountId: String): Builder = apply { this.accountId = accountId }
fun withRegion(region: String): Builder = apply { this.region = region }
fun withBonsaiSnsEnvironmentDefinition(bonsaiSnsEnvironment: BonsaiSnsEnvironment): Builder =
apply { this.bonsaiSnsEnvironment = bonsaiSnsEnvironment }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal class AwsSnsInterfaceTest {
private val basicAWSCredentials = BasicAWSCredentials("foo", "bar")
private const val region = "region"
private const val port = 7979
private const val accountId = 123456789L
private const val accountId = "123456789"

@JvmStatic
@BeforeAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.junit.jupiter.api.TestInstance

@TestInstance(TestInstance.Lifecycle.PER_METHOD)
internal class MessageFactoryTest {
private val config = BonsaiSnsConfig(1234, "region", 123456789)
private val config = BonsaiSnsConfig(1234, "region", "123456789")
private val subscription = mockk<Subscription>()
private lateinit var messageFactory: MessageFactory

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import org.junit.jupiter.api.assertThrows

@TestInstance(TestInstance.Lifecycle.PER_METHOD)
internal class SubscriptionManagerTest {
private val config = BonsaiSnsConfig(1234, "region", 123456789)
private val config = BonsaiSnsConfig(1234, "region", "123456789")
private val snsOpActor = snsOpsActor()
private val subscriptionManager = SubscriptionManager(snsOpActor, config)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.junit.jupiter.api.assertThrows

@TestInstance(TestInstance.Lifecycle.PER_METHOD)
internal class TopicManagerTest {
private val config = BonsaiSnsConfig(1234, "region", 123456789)
private val config = BonsaiSnsConfig(1234, "region", "123456789")
private val topicManager = TopicManager(snsOpsActor(), config)

@Test
Expand Down

0 comments on commit d5c3951

Please sign in to comment.