### Question:
DefaultNameInitializer implements DeviceInitializer { @Override public void intialize(DeviceDriverContext context) { String name; try { String productId = context.getAttributeValue(ATTR_PRODUCT_ID); String population = getPopulation(context.getPlaceId()); name = getNameForProductId(productId, population); name = uniquefy(context.getPlaceId(), name); } catch(Exception e) { logger.warn("Error resolving default name", e); name = defaultName; } logger.debug("Setting device name to {}", name); context.setAttributeValue(ATTR_NAME, name); } @Inject  DefaultNameInitializer(
         ProductCatalogManager catalogManager,
         PlacePopulationCacheManager populationCacheMgr,
         PopulationDAO populationDao,
         DeviceDAO deviceDao
   ); @Override void intialize(DeviceDriverContext context);  }### Answer:
@Test public void testDefaultName() { expectFindPlaceAndReturn(); expectGetProductAndReturnEmpty(); expectListDevicesAndReturnNames(); expectSetName("New Device 1"); replay(); initializer.intialize(context); verify(); }
@Test public void testDefaultNameIncrementsNumber() { expectFindPlaceAndReturn(); expectGetProductAndReturnEmpty(); expectListDevicesAndReturnNames("Some Random Name", "New Device", "New Device 2", "New Device 100"); expectSetName("New Device 101"); replay(); initializer.intialize(context); verify(); }
@Test public void testProductName() { expectFindPlaceAndReturn(); expectGetProductAndReturn("Vendor", "Magiks"); expectListDevicesAndReturnNames("Some Random Name", "New Device", "New Device 2", "New Device 100"); expectSetName("Vendor Magiks 1"); replay(); initializer.intialize(context); verify(); }