Skip to content

Commit

Permalink
MODULE: Move tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-at-work authored and albertogpz committed Feb 4, 2022
1 parent 07884e8 commit 5aa6bc7
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 3 deletions.
7 changes: 7 additions & 0 deletions geode-wan-txgrouping/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ dependencies {
implementation(project(':geode-serialization'))
implementation(project(':geode-core'))


// test
testImplementation(project(':geode-junit'))
testImplementation('org.assertj:assertj-core')
testImplementation('junit:junit')
testImplementation('org.mockito:mockito-core')

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.geode.cache.wan.internal.txgrouping.parallel;

import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.Test;

import org.apache.geode.internal.cache.wan.GatewaySenderException;
import org.apache.geode.internal.cache.wan.MutableGatewaySenderAttributes;

public class TxGroupingParallelGatewaySenderTypeFactoryTest {

final TxGroupingParallelGatewaySenderTypeFactory factory =
new TxGroupingParallelGatewaySenderTypeFactory();

@Test
public void validateThrowsIfBatchConflationEnabled() {
final MutableGatewaySenderAttributes attributes = mock(MutableGatewaySenderAttributes.class);
when(attributes.isBatchConflationEnabled()).thenReturn(true);

assertThatThrownBy(() -> factory.validate(attributes))
.isInstanceOf(GatewaySenderException.class)
.hasMessageContaining(
"both group transaction events set to true and batch conflation enabled");
}

@Test
public void validateDoesNotThrowsIfBatchConflationDisabled() {
final MutableGatewaySenderAttributes attributes = mock(MutableGatewaySenderAttributes.class);
when(attributes.isBatchConflationEnabled()).thenReturn(false);

assertThatNoException().isThrownBy(() -> factory.validate(attributes));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* 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.geode.cache.wan.internal.txgrouping.serial;

import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.Test;

import org.apache.geode.internal.cache.wan.GatewaySenderException;
import org.apache.geode.internal.cache.wan.MutableGatewaySenderAttributes;

public class TxGroupingSerialGatewaySenderTypeFactoryTest {

final TxGroupingSerialGatewaySenderTypeFactory factory =
new TxGroupingSerialGatewaySenderTypeFactory();

final MutableGatewaySenderAttributes attributes = mock(MutableGatewaySenderAttributes.class);

@Test
public void validateThrowsIfBatchConflationEnabled() {
when(attributes.isBatchConflationEnabled()).thenReturn(true);

assertThatThrownBy(() -> factory.validate(attributes))
.isInstanceOf(GatewaySenderException.class)
.hasMessageContaining(
"both group transaction events set to true and batch conflation enabled");
}

@Test
public void validateDoesNotThrowsIfBatchConflationDisabled() {
when(attributes.isBatchConflationEnabled()).thenReturn(false);

assertThatNoException().isThrownBy(() -> factory.validate(attributes));
}

@Test
public void validateThrowsIfDispatcherThreadsGreaterThan1() {
when(attributes.getDispatcherThreads()).thenReturn(2);

assertThatThrownBy(() -> factory.validate(attributes))
.isInstanceOf(GatewaySenderException.class).hasMessageContaining(
"cannot be created with group transaction events set to true when dispatcher threads is greater than 1");
}

@Test
public void validateDoesNotThrow() {
when(attributes.getDispatcherThreads()).thenReturn(1);

assertThatNoException().isThrownBy(() -> factory.validate(attributes));
}


}
3 changes: 0 additions & 3 deletions geode-wan/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ dependencies {
testImplementation('junit:junit')
testImplementation('org.mockito:mockito-core')

// TODO jbarrett remove
testRuntimeOnly(project(':geode-wan-txgrouping'))

integrationTestImplementation(project(':geode-junit'))
integrationTestImplementation('org.assertj:assertj-core')
integrationTestImplementation('junit:junit')
Expand Down

0 comments on commit 5aa6bc7

Please sign in to comment.