-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
21 changed files
with
945 additions
and
10 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
44 changes: 44 additions & 0 deletions
44
cluster-boost-ignite/src/test/java/com/technologicgroup/boost/chain/ChainBeanCommonTest.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,44 @@ | ||
package com.technologicgroup.boost.chain; | ||
|
||
import com.technologicgroup.boost.core.Cluster; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
import org.springframework.context.ApplicationContext; | ||
|
||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ChainBeanCommonTest { | ||
|
||
@Mock | ||
private Cluster cluster; | ||
|
||
@Mock | ||
private ApplicationContext context; | ||
|
||
@InjectMocks | ||
private ChainBeanCommon<?, ?> chainBean; | ||
|
||
@Test | ||
public void testGetBean_OK() { | ||
chainBean.getBean(Object.class); | ||
verify(context, times(1)).getBean(Object.class); | ||
} | ||
|
||
@Test | ||
public void testOnFinishBean_OK() { | ||
chainBean.onFinishBean("", null, null, null, null, null); | ||
verify(cluster, times(1)).getLocalNode(); | ||
} | ||
|
||
@Test | ||
public void testOnStartBean_OK() { | ||
chainBean.onStartBean("", null, null); | ||
verify(cluster, times(1)).getLocalNode(); | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
...-boost-ignite/src/test/java/com/technologicgroup/boost/chain/ChainFilterBeanImplTest.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,56 @@ | ||
package com.technologicgroup.boost.chain; | ||
|
||
import com.technologicgroup.boost.core.Cluster; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.UUID; | ||
|
||
import static org.mockito.Mockito.*; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ChainFilterBeanImplTest { | ||
|
||
@Mock | ||
private Cluster cluster; | ||
|
||
@InjectMocks | ||
private ChainFilterBeanImpl<Integer> chainFilter; | ||
|
||
@Test | ||
public void testRun_filtered_OK() { | ||
String nodeId = UUID.randomUUID().toString(); | ||
Integer nodeResult = 100; | ||
|
||
Collection<ChainResult<Integer>> chainResults = new ArrayList<>(); | ||
chainResults.add(new ChainResult<>(nodeId, nodeResult)); | ||
|
||
when(cluster.getLocalNode()).thenReturn(nodeId); | ||
Integer result = chainFilter.run(chainResults); | ||
|
||
verify(cluster, times(1)).getLocalNode(); | ||
Assert.assertEquals(nodeResult, result); | ||
} | ||
|
||
@Test | ||
public void testRun_filtered_Null() { | ||
String nodeId = UUID.randomUUID().toString(); | ||
Integer nodeResult = 100; | ||
|
||
Collection<ChainResult<Integer>> chainResults = new ArrayList<>(); | ||
chainResults.add(new ChainResult<>(nodeId, nodeResult)); | ||
|
||
when(cluster.getLocalNode()).thenReturn(UUID.randomUUID().toString()); | ||
Integer result = chainFilter.run(chainResults); | ||
|
||
verify(cluster, times(1)).getLocalNode(); | ||
Assert.assertNull(result); | ||
} | ||
|
||
} |
94 changes: 94 additions & 0 deletions
94
...-boost-ignite/src/test/java/com/technologicgroup/boost/common/CommonDataAccessorTest.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,94 @@ | ||
package com.technologicgroup.boost.common; | ||
|
||
import org.apache.ignite.IgniteCache; | ||
import org.apache.ignite.cache.query.QueryCursor; | ||
import org.apache.ignite.cache.query.ScanQuery; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import javax.cache.Cache; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import static org.mockito.Mockito.*; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class CommonDataAccessorTest { | ||
|
||
@Mock | ||
private CommonRepository<Integer, Integer> repository; | ||
|
||
@Mock | ||
private IgniteCache<Integer, Integer> cache; | ||
|
||
@Mock | ||
private QueryCursor<Cache.Entry<Integer, Integer>> cursor; | ||
|
||
public static class DataAccessor extends CommonDataAccessor<Integer, Integer> { | ||
public DataAccessor(CommonRepository<Integer, Integer> repository) { | ||
super(repository); | ||
} | ||
} | ||
|
||
@Test | ||
public void testNetworkGet_one_OK() { | ||
DataAccessor dataAccessor = new DataAccessor(repository); | ||
when(repository.cache()).thenReturn(cache); | ||
|
||
dataAccessor.networkGet(1); | ||
verify(cache, times(1)).get(1); | ||
} | ||
|
||
@Test | ||
public void testNetworkGet_keys_OK() { | ||
DataAccessor dataAccessor = new DataAccessor(repository); | ||
when(repository.cache()).thenReturn(cache); | ||
|
||
Set<Integer> keys = Collections.singleton(1); | ||
dataAccessor.networkGet(keys); | ||
verify(cache, times(1)).getAll(keys); | ||
} | ||
|
||
@Test | ||
@SuppressWarnings("unchecked") | ||
public void testNetworkGet_all_OK() { | ||
DataAccessor dataAccessor = new DataAccessor(repository); | ||
when(repository.cache()).thenReturn(cache); | ||
when(cache.query(any(ScanQuery.class))).thenReturn(cursor); | ||
|
||
dataAccessor.networkGetAll(); | ||
verify(cache, times(1)).query(any(ScanQuery.class)); | ||
} | ||
|
||
@Test | ||
public void testPut_one_OK() { | ||
DataAccessor dataAccessor = new DataAccessor(repository); | ||
|
||
dataAccessor.put(1, 0); | ||
verify(repository, times(1)).put(1, 0); | ||
} | ||
|
||
@Test | ||
public void testPut_all_OK() { | ||
DataAccessor dataAccessor = new DataAccessor(repository); | ||
|
||
Map<Integer, Integer> map = Collections.singletonMap(1, 0); | ||
dataAccessor.putAll(map); | ||
verify(repository, times(1)).putAll(map); | ||
} | ||
|
||
@Test | ||
@SuppressWarnings("unchecked") | ||
public void testFind_OK() { | ||
DataAccessor dataAccessor = new DataAccessor(repository); | ||
when(repository.cache()).thenReturn(cache); | ||
when(cache.query(any(ScanQuery.class))).thenReturn(cursor); | ||
|
||
dataAccessor.find((i) -> true); | ||
verify(cache, times(1)).query(any(ScanQuery.class)); | ||
} | ||
|
||
} |
Oops, something went wrong.