示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testResourceRetrieval()
        public virtual void testResourceRetrieval()
        {
            cache.put("hello", "world");

            assertNull(cache.get(null));
            assertNull(cache.get("unknown"));
            assertEquals("world", cache.get("hello"));
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testIdentityLinkCaching()
        public virtual void testIdentityLinkCaching()
        {
            string[] taskIds = new string[] { "test" };
            // mock identityLinks and query
            IdentityLink link1 = mock(typeof(IdentityLink));

            when(link1.TaskId).thenReturn(taskIds[0]);
            IdentityLink link2 = mock(typeof(IdentityLink));

            when(link2.TaskId).thenReturn(taskIds[0]);
            when(processEngine.TaskService.getIdentityLinksForTask(anyString())).thenReturn(Arrays.asList(link1, link2));

            // configure cache
            HalRelationCacheConfiguration configuration = new HalRelationCacheConfiguration();

            configuration.CacheImplementationClass = typeof(DefaultHalResourceCache);
            IDictionary <string, object> halIdentityLinkConfig = new Dictionary <string, object>();

            halIdentityLinkConfig["capacity"]      = 100;
            halIdentityLinkConfig["secondsToLive"] = 10000;
            configuration.addCacheConfiguration(typeof(HalIdentityLink), halIdentityLinkConfig);

            contextListener.configureCaches(configuration);

            // cache exists and is empty
            DefaultHalResourceCache cache = (DefaultHalResourceCache)Hal.Instance.getHalRelationCache(typeof(HalIdentityLink));

            assertNotNull(cache);
            assertEquals(0, cache.size());

            // get link resolver and resolve identity link
            HalLinkResolver linkResolver = Hal.Instance.getLinkResolver(typeof(IdentityRestService));
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.camunda.bpm.engine.rest.hal.HalResource<?>> halIdentityLinks = linkResolver.resolveLinks(taskIds, processEngine);
            IList <HalResource <object> > halIdentityLinks = linkResolver.resolveLinks(taskIds, processEngine);

            assertEquals(2, halIdentityLinks.Count);
            assertEquals(1, cache.size());

            assertEquals(halIdentityLinks, cache.get(taskIds[0]));
        }