### Question:
AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSection = true; m_currentUser = tokens[1]; m_parsingPatternSpecificSection = false; return null; case "pattern": m_parsingUsersSpecificSection = false; m_currentUser = ""; m_parsingPatternSpecificSection = true; return createAuthorization(line, tokens); default: throw new ParseException(String.format("invalid line definition found %s", line), 1); } }  @Override boolean canWrite(Topic topic, String user, String client); @Override boolean canRead(Topic topic, String user, String client); boolean isEmpty();  }### Answer:
@Test public void testParseAuthLineValid() throws ParseException { Authorization authorization = authorizator.parseAuthLine("topic /weather/italy/anemometer"); assertEquals(RW_ANEMOMETER, authorization); }
@Test public void testParseAuthLineValid_read() throws ParseException { Authorization authorization = authorizator.parseAuthLine("topic read /weather/italy/anemometer"); assertEquals(R_ANEMOMETER, authorization); }
@Test public void testParseAuthLineValid_write() throws ParseException { Authorization authorization = authorizator.parseAuthLine("topic write /weather/italy/anemometer"); assertEquals(W_ANEMOMETER, authorization); }
@Test public void testParseAuthLineValid_readwrite() throws ParseException { Authorization authorization = authorizator.parseAuthLine("topic readwrite /weather/italy/anemometer"); assertEquals(RW_ANEMOMETER, authorization); }
@Test public void testParseAuthLineValid_topic_with_space() throws ParseException { Authorization expected = new Authorization(new Topic("/weather/eastern italy/anemometer")); Authorization authorization = authorizator.parseAuthLine("topic readwrite /weather/eastern italy/anemometer"); assertEquals(expected, authorization); }
@Test(expected = ParseException.class) public void testParseAuthLineValid_invalid() throws ParseException { authorizator.parseAuthLine("topic faker /weather/italy/anemometer"); }