# Mocking Cache Manage for Active Objects Test

**URL:** <https://community.developer.atlassian.com/t/mocking-cache-manage-for-active-objects-test/41748>\
**Category:** Everything Else\
**Tags:** cache, active-objects, jira-server\
**Created:** [September 23, 2020, 2:07pm UTC](https://community.developer.atlassian.com/t/mocking-cache-manage-for-active-objects-test/41748 "2020-09-23T14:07:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PurusothamanRamanuja](https://avatars.discourse-cdn.com/v4/letter/p/d78d45/32.png) [@PurusothamanRamanuja](https://community.developer.atlassian.com/u/PurusothamanRamanuja)\
**Post date:** [September 23, 2020, 2:07pm UTC](https://community.developer.atlassian.com/t/mocking-cache-manage-for-active-objects-test/41748/1 "2020-09-23T14:07:21Z")

</div>

I am creating a test for Active Objects. My service implementation depends on Active Object and CacheManage objects as shown below.

```auto
    @Before
    public void setUp() throws Exception {
        assertNotNull(entityManager);

        ao = new TestActiveObjects(entityManager);
        projectService = new ProjectServiceImpl(ao, cacheManager); //how to initialize?
    }

```

How do I create test for such service implementation? My service methods depends on cache. Is there any mock cache manager available?

---

<div class="post-metadata">

**Author:** ![jkells](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/jkells/32/36611_2.png) [@jkells](https://community.developer.atlassian.com/u/jkells)\
**Post date:** [November 2, 2021, 5:34am UTC](https://community.developer.atlassian.com/t/mocking-cache-manage-for-active-objects-test/41748/2 "2021-11-02T05:34:56Z")

</div>

Just ran into this issue today.

You can use the `com.atlassian.cache.memory.MemoryCacheManager` class as a drop in CacheManager for your tests.

Just add the relevant import to your pom:

```auto
    <dependency>
      <groupId>com.atlassian.cache</groupId>
      <artifactId>atlassian-cache-memory</artifactId>
      <version>${cache-version}</version>
      <scope>test</scope>
    </dependency>

```
