### Question:
RateLimitingPolicy extends AbstractMappedPolicy<RateLimitingConfig> { protected static RateBucketPeriod getPeriod(RateLimitingConfig config) { RateLimitingPeriod period = config.getPeriod(); switch (period) { case Second: return RateBucketPeriod.Second; case Day: return RateBucketPeriod.Day; case Hour: return RateBucketPeriod.Hour; case Minute: return RateBucketPeriod.Minute; case Month: return RateBucketPeriod.Month; case Year: return RateBucketPeriod.Year; default: return RateBucketPeriod.Month; } } RateLimitingPolicy();   }### Answer:
@Test public void testParseConfiguration() { RateLimitingPolicy policy = new RateLimitingPolicy(); String config = "{}"; Object parsed = policy.parseConfiguration(config); Assert.assertNotNull(parsed); Assert.assertEquals(RateLimitingConfig.class, parsed.getClass()); RateLimitingConfig parsedConfig = (RateLimitingConfig) parsed; Assert.assertNull(parsedConfig.getUserHeader()); Assert.assertNull(parsedConfig.getGranularity()); Assert.assertNull(parsedConfig.getPeriod()); config = "{\r\n" + " \"limit\" : 100,\r\n" + " \"granularity\" : \"User\",\r\n" + " \"period\" : \"Day\",\r\n" + " \"headerRemaining\" : \"X-Rate-Remaining\",\r\n" + " \"headerLimit\" : \"X-Rate-Limit\",\r\n" + " \"headerReset\" : \"X-Rate-Reset\",\r\n" + " \"userHeader\" : \"X-Authenticated-Identity\"\r\n" + "}"; parsed = policy.parseConfiguration(config); parsedConfig = (RateLimitingConfig) parsed; Assert.assertNotNull(parsedConfig.getUserHeader()); Assert.assertNotNull(parsedConfig.getGranularity()); Assert.assertNotNull(parsedConfig.getLimit()); Assert.assertNotNull(parsedConfig.getPeriod()); Assert.assertEquals("X-Authenticated-Identity", parsedConfig.getUserHeader()); Assert.assertEquals(RateLimitingGranularity.User, parsedConfig.getGranularity()); Assert.assertEquals(100, parsedConfig.getLimit()); Assert.assertEquals(RateLimitingPeriod.Day, parsedConfig.getPeriod()); Assert.assertEquals("X-Rate-Limit", parsedConfig.getHeaderLimit()); Assert.assertEquals("X-Rate-Remaining", parsedConfig.getHeaderRemaining()); Assert.assertEquals("X-Rate-Reset", parsedConfig.getHeaderReset()); }