test_class.declarator: e1a
test_class.modifier: protected
test_class.original_string: protected Entity e1a;
test_class.type: Entity
test_class.var_name: e1a
test_class.declarator: e1b
test_class.modifier: protected
test_class.original_string: protected Entity e1b;
test_class.type: Entity
test_class.var_name: e1b
test_class.declarator: d1
test_class.modifier: protected
test_class.original_string: protected Device d1;
test_class.type: Device
test_class.var_name: d1
test_class.declarator: e2
test_class.modifier: protected
test_class.original_string: protected Entity e2;
test_class.type: Entity
test_class.var_name: e2
test_class.declarator: e2alt
test_class.modifier: protected
test_class.original_string: protected Entity e2alt;
test_class.type: Entity
test_class.var_name: e2alt
test_class.declarator: e3
test_class.modifier: protected
test_class.original_string: protected Entity e3;
test_class.type: Entity
test_class.var_name: e3
test_class.declarator: e4
test_class.modifier: protected
test_class.original_string: protected Entity e4;
test_class.type: Entity
test_class.var_name: e4
test_class.file: src/agents/apps/floodlight/floodlight-1.2/src/test/java/net/floodlightcontroller/devicemanager/internal/DeviceUniqueIndexTest.java
test_class.identifier: DeviceUniqueIndexTest
test_class.superclass: extends TestCase
test_case.body: @Test
      public void testDeviceUniqueIndex() {
          DeviceUniqueIndex idx1 = new DeviceUniqueIndex(
                                               EnumSet.of(DeviceField.MAC, 
                                                          DeviceField.VLAN));
          
          idx1.updateIndex(d1, d1.getDeviceKey());
          idx1.updateIndex(e2, 2L);
          
          //-------------
          // Test findByEntity lookups
          assertEquals(Long.valueOf(1L), idx1.findByEntity(e1a));
          assertEquals(Long.valueOf(1L), idx1.findByEntity(e1b));
          assertEquals(Long.valueOf(2L), idx1.findByEntity(e2));
          // we didn't add e2alt but since they key fields are the same we 
          // should find it 
          assertEquals(Long.valueOf(2L), idx1.findByEntity(e2alt));
          assertEquals(null, idx1.findByEntity(e3));
          assertEquals(null, idx1.findByEntity(e4));
          
          //-------------
          // Test getAll()
          HashSet<Long> expectedKeys = new HashSet<Long>();
          expectedKeys.add(1L);
          expectedKeys.add(2L);
          verifyIterator(expectedKeys, idx1.getAll());
          
                  
          //-------------
          // Test queryByEntity()
          verifyIterator(Collections.<Long>singleton(1L), 
                         idx1.queryByEntity(e1a));
          verifyIterator(Collections.<Long>singleton(1L), 
                         idx1.queryByEntity(e1b));
          verifyIterator(Collections.<Long>singleton(2L), 
                         idx1.queryByEntity(e2));
          verifyIterator(Collections.<Long>singleton(2L),
                         idx1.queryByEntity(e2alt));
          assertEquals(false, idx1.queryByEntity(e3).hasNext());
          assertEquals(false, idx1.queryByEntity(e3).hasNext());
          
          
          //-------------
          // Test removal
          idx1.removeEntity(e1a, 42L); // No-op. e1a isn't mapped to this key
          assertEquals(Long.valueOf(1L), idx1.findByEntity(e1a));
          idx1.removeEntity(e1a, 1L); 
          assertEquals(null, idx1.findByEntity(e1a));
          assertEquals(Long.valueOf(1L), idx1.findByEntity(e1b));
          assertEquals(Long.valueOf(2L), idx1.findByEntity(e2));
          idx1.removeEntity(e2);  
          assertEquals(null, idx1.findByEntity(e2));
          assertEquals(Long.valueOf(1L), idx1.findByEntity(e1b));
          
          
          //-------------
          // Test null keys
          DeviceUniqueIndex idx2 = new DeviceUniqueIndex(
                                               EnumSet.of(DeviceField.IPv4,
                                              		 	DeviceField.IPv6,
                                                          DeviceField.SWITCH));
          // only one key field is null
          idx2.updateIndex(e3, 3L);
          assertEquals(Long.valueOf(3L), idx2.findByEntity(e3));
          e3.ipv4Address = IPv4Address.of(3);
          assertEquals(null, idx2.findByEntity(e3));
          // all key fields are null
          idx2.updateIndex(e4, 4L);
          assertEquals(null, idx2.findByEntity(e4));
          Device d4 = new Device(null, 4L, null, null, null,
                                 Collections.<Entity>singleton(e4), null);
          idx2.updateIndex(d4, 4L);
          assertEquals(null, idx2.findByEntity(e4));
          
          
  
          //-------------
          // entity already exists with different deviceKey
          DeviceUniqueIndex idx3 = new DeviceUniqueIndex(
                                               EnumSet.of(DeviceField.MAC, 
                                                          DeviceField.VLAN));
          idx3.updateIndex(e1a, 42L);
          assertEquals(false, idx3.updateIndex(d1, 1L));
          // TODO: shouldn't this fail as well so that the behavior
          // is consistent?
          idx3.updateIndex(e1a, 1L);
          // anyways. We can now add d1 ;-)
          assertEquals(true, idx3.updateIndex(d1, 1L));
      }
test_case.class_method_signature: DeviceUniqueIndexTest.testDeviceUniqueIndex()
test_case.full_signature: @Test public void testDeviceUniqueIndex()
test_case.identifier: testDeviceUniqueIndex
test_case.invocations: of updateIndex getDeviceKey updateIndex assertEquals valueOf findByEntity assertEquals valueOf findByEntity assertEquals valueOf findByEntity assertEquals valueOf findByEntity assertEquals findByEntity assertEquals findByEntity add add verifyIterator getAll verifyIterator singleton queryByEntity verifyIterator singleton queryByEntity verifyIterator singleton queryByEntity verifyIterator singleton queryByEntity assertEquals hasNext queryByEntity assertEquals hasNext queryByEntity removeEntity assertEquals valueOf findByEntity removeEntity assertEquals findByEntity assertEquals valueOf findByEntity assertEquals valueOf findByEntity removeEntity assertEquals findByEntity assertEquals valueOf findByEntity of updateIndex assertEquals valueOf findByEntity of assertEquals findByEntity updateIndex assertEquals findByEntity singleton updateIndex assertEquals findByEntity of updateIndex assertEquals updateIndex updateIndex assertEquals updateIndex
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDeviceUniqueIndex()
focal_class.declarator: index
focal_class.modifier: private final
focal_class.original_string: private final ConcurrentHashMap<IndexedEntity, Long> index;
focal_class.type: ConcurrentHashMap<IndexedEntity, Long>
focal_class.var_name: index
focal_class.file: src/agents/apps/floodlight/floodlight-1.2/src/main/java/net/floodlightcontroller/devicemanager/internal/DeviceUniqueIndex.java
focal_class.identifier: DeviceUniqueIndex
focal_class.class_method_signature: DeviceUniqueIndex.DeviceUniqueIndex(EnumSet<DeviceField> keyFields)
focal_class.full_signature: public  DeviceUniqueIndex(EnumSet<DeviceField> keyFields)
focal_class.identifier: DeviceUniqueIndex
focal_class.modifiers: public
focal_class.parameters: (EnumSet<DeviceField> keyFields)
focal_class.signature:  DeviceUniqueIndex(EnumSet<DeviceField> keyFields)
focal_class.class_method_signature: DeviceUniqueIndex.queryByEntity(Entity entity)
focal_class.full_signature: @Override public Iterator<Long> queryByEntity(Entity entity)
focal_class.identifier: queryByEntity
focal_class.modifiers: @Override public
focal_class.parameters: (Entity entity)
focal_class.return: Iterator<Long>
focal_class.signature: Iterator<Long> queryByEntity(Entity entity)
focal_class.class_method_signature: DeviceUniqueIndex.getAll()
focal_class.full_signature: @Override public Iterator<Long> getAll()
focal_class.identifier: getAll
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Iterator<Long>
focal_class.signature: Iterator<Long> getAll()
focal_class.class_method_signature: DeviceUniqueIndex.updateIndex(Device device, Long deviceKey)
focal_class.full_signature: @Override public boolean updateIndex(Device device, Long deviceKey)
focal_class.identifier: updateIndex
focal_class.modifiers: @Override public
focal_class.parameters: (Device device, Long deviceKey)
focal_class.return: boolean
focal_class.signature: boolean updateIndex(Device device, Long deviceKey)
focal_class.class_method_signature: DeviceUniqueIndex.updateIndex(Entity entity, Long deviceKey)
focal_class.full_signature: @Override public boolean updateIndex(Entity entity, Long deviceKey)
focal_class.identifier: updateIndex
focal_class.modifiers: @Override public
focal_class.parameters: (Entity entity, Long deviceKey)
focal_class.return: boolean
focal_class.signature: boolean updateIndex(Entity entity, Long deviceKey)
focal_class.class_method_signature: DeviceUniqueIndex.removeEntity(Entity entity)
focal_class.full_signature: @Override public void removeEntity(Entity entity)
focal_class.identifier: removeEntity
focal_class.modifiers: @Override public
focal_class.parameters: (Entity entity)
focal_class.return: void
focal_class.signature: void removeEntity(Entity entity)
focal_class.class_method_signature: DeviceUniqueIndex.removeEntity(Entity entity, Long deviceKey)
focal_class.full_signature: @Override public void removeEntity(Entity entity, Long deviceKey)
focal_class.identifier: removeEntity
focal_class.modifiers: @Override public
focal_class.parameters: (Entity entity, Long deviceKey)
focal_class.return: void
focal_class.signature: void removeEntity(Entity entity, Long deviceKey)
focal_class.class_method_signature: DeviceUniqueIndex.findByEntity(Entity entity)
focal_class.full_signature: public Long findByEntity(Entity entity)
focal_class.identifier: findByEntity
focal_class.modifiers: public
focal_class.parameters: (Entity entity)
focal_class.return: Long
focal_class.signature: Long findByEntity(Entity entity)
focal_class.superclass: extends DeviceIndex
focal_method.body: public DeviceUniqueIndex(EnumSet<DeviceField> keyFields) {
          super(keyFields);
          index = new ConcurrentHashMap<IndexedEntity, Long>();
      }
focal_method.class_method_signature: DeviceUniqueIndex.DeviceUniqueIndex(EnumSet<DeviceField> keyFields)
focal_method.full_signature: public  DeviceUniqueIndex(EnumSet<DeviceField> keyFields)
focal_method.identifier: DeviceUniqueIndex
focal_method.modifiers: public
focal_method.parameters: (EnumSet<DeviceField> keyFields)
focal_method.signature:  DeviceUniqueIndex(EnumSet<DeviceField> keyFields)