use of org.opennms.newts.api.Context in project opennms by OpenNMS.
the class RedisResourceMetadataCacheIT method canUpdateEntry.
@Test
public void canUpdateEntry() {
Context ctx = Context.DEFAULT_CONTEXT;
RedisResourceMetadataCache cache = new RedisResourceMetadataCache(REDIS_HOSTNAME, REDIS_PORT, 8, m_registry, new EscapableResourceIdSplitter());
// Insert
Resource resource = new Resource("a:b:c");
ResourceMetadata resourceMetadata = new ResourceMetadata();
resourceMetadata.putAttribute("a1", "1");
cache.merge(ctx, resource, resourceMetadata);
// Verify
assertTrue("attribute a1 must be set", cache.get(ctx, resource).get().containsAttribute("a1", "1"));
// Update
resourceMetadata = new ResourceMetadata();
resourceMetadata.putAttribute("a2", "2");
cache.merge(ctx, resource, resourceMetadata);
// Verify
assertTrue("attribute a1 must be set", cache.get(ctx, resource).get().containsAttribute("a1", "1"));
assertTrue("attribute a2 must be set", cache.get(ctx, resource).get().containsAttribute("a2", "2"));
}
use of org.opennms.newts.api.Context in project opennms by OpenNMS.
the class NewtsFetchStrategyTest method setUp.
@Before
public void setUp() throws Exception {
m_context = new Context("test");
m_resourceDao = EasyMock.createNiceMock(ResourceDao.class);
m_sampleRepository = EasyMock.createNiceMock(SampleRepository.class);
m_newtsFetchStrategy = new NewtsFetchStrategy();
m_newtsFetchStrategy.setContext(m_context);
m_newtsFetchStrategy.setResourceDao(m_resourceDao);
m_newtsFetchStrategy.setSampleRepository(m_sampleRepository);
}
Aggregations