-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not remove subscription if it already existed before subscription …
…creation (#1887) * do not remove subscription if it already existed before subscription creation * fix MultiDatacenterRepositoryCommandExecutorTest
- Loading branch information
Showing
30 changed files
with
92 additions
and
34 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
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
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
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
53 changes: 53 additions & 0 deletions
53
...es/management/domain/subscription/commands/CreateSubscriptionRepositoryCommandTest.groovy
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,53 @@ | ||
package pl.allegro.tech.hermes.management.domain.subscription.commands | ||
|
||
import pl.allegro.tech.hermes.api.Subscription | ||
import pl.allegro.tech.hermes.api.TopicName | ||
import pl.allegro.tech.hermes.domain.subscription.SubscriptionAlreadyExistsException | ||
import pl.allegro.tech.hermes.domain.subscription.SubscriptionRepository | ||
import pl.allegro.tech.hermes.management.domain.dc.DatacenterBoundRepositoryHolder | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
|
||
import static pl.allegro.tech.hermes.test.helper.builder.SubscriptionBuilder.subscription | ||
|
||
class CreateSubscriptionRepositoryCommandTest extends Specification { | ||
|
||
@Shared | ||
def topicName = new TopicName("group", "topic") | ||
|
||
@Shared | ||
def subscriptionName = "subscription" | ||
|
||
@Shared | ||
Subscription subscription = subscription(topicName, subscriptionName).build() | ||
|
||
def "should not remove subscription if subscription already exists during rollback"() { | ||
given: | ||
SubscriptionRepository subscriptionRepository = Mock(SubscriptionRepository) | ||
DatacenterBoundRepositoryHolder<SubscriptionRepository> repository = Mock(DatacenterBoundRepositoryHolder) { | ||
getRepository() >> subscriptionRepository | ||
} | ||
def command = new CreateSubscriptionRepositoryCommand(subscription) | ||
|
||
when: | ||
command.rollback(repository, new SubscriptionAlreadyExistsException(subscription)) | ||
|
||
then: | ||
0 * subscriptionRepository.removeSubscription(topicName, subscriptionName) | ||
} | ||
|
||
def "should remove subscription during rollback"() { | ||
given: | ||
SubscriptionRepository subscriptionRepository = Mock(SubscriptionRepository) | ||
DatacenterBoundRepositoryHolder<SubscriptionRepository> repository = Mock(DatacenterBoundRepositoryHolder) { | ||
getRepository() >> subscriptionRepository | ||
} | ||
def command = new CreateSubscriptionRepositoryCommand(subscription) | ||
|
||
when: | ||
command.rollback(repository, new RuntimeException()) | ||
|
||
then: | ||
1 * subscriptionRepository.removeSubscription(topicName, subscriptionName) | ||
} | ||
} |