public void addResources(ConcurrentMap<String, ? extends LocallyCachedBlob> blobs) {
        for (LocallyCachedBlob b : blobs.values()) {
            currentSize += b.getSizeOnDisk();
            if (b.isUsed()) {
                LOG.debug("NOT going to clean up {}, {} depends on it", b.getKey(), b.getDependencies());
                // always retain resources in use
                continue;
            }
            LOG.debug("Possibly going to clean up {} ts {} size {}", b.getKey(), b.getLastUsed(), b.getSizeOnDisk());
            noReferences.put(b, blobs);
        }
    }
@Test
    public void testAddResources() {
        PortAndAssignment pna1 = new PortAndAssignmentImpl(1, new LocalAssignment("topo1", Collections.emptyList()));
        PortAndAssignment pna2 = new PortAndAssignmentImpl(1, new LocalAssignment("topo2", Collections.emptyList()));
        String user = "user";
        Map<String, Object> conf = new HashMap<>();
        IAdvancedFSOps ops = mock(IAdvancedFSOps.class);
        LocalizedResourceRetentionSet lrretset = new LocalizedResourceRetentionSet(10);
        ConcurrentMap<String, LocalizedResource> lrset = new ConcurrentHashMap<>();
        StormMetricsRegistry metricsRegistry = new StormMetricsRegistry();
        LocalizedResource localresource1 = new LocalizedResource("key1", Paths.get("testfile1"), false, ops, conf, user, metricsRegistry);
        localresource1.addReference(pna1, null);
        LocalizedResource localresource2 = new LocalizedResource("key2", Paths.get("testfile2"), false, ops, conf, user, metricsRegistry);
        localresource2.addReference(pna1, null);
        // check adding reference to local resource with topology of same name
        localresource2.addReference(pna2, null);

        lrset.put("key1", localresource1);
        lrset.put("key2", localresource2);
        lrretset.addResources(lrset);
        assertEquals(0, lrretset.getSizeWithNoReferences(), "number to clean is not 0 " + lrretset.noReferences);
        assertTrue(localresource1.removeReference(pna1));
        lrretset = new LocalizedResourceRetentionSet(10);
        lrretset.addResources(lrset);
        assertEquals(1, lrretset.getSizeWithNoReferences(), "number to clean is not 1 " + lrretset.noReferences);

        assertTrue(localresource2.removeReference(pna1));
        lrretset = new LocalizedResourceRetentionSet(10);
        lrretset.addResources(lrset);
        assertEquals(1, lrretset.getSizeWithNoReferences(), "number to clean is not 1  " + lrretset.noReferences);

        assertTrue(localresource2.removeReference(pna2));
        lrretset = new LocalizedResourceRetentionSet(10);
        lrretset.addResources(lrset);
        assertEquals(2, lrretset.getSizeWithNoReferences(), "number to clean is not 2 " + lrretset.noReferences);
    }