PageView { public static PageView fromString(String pv) { LOG.debug("get string '" + pv + "'"); String[] parts = pv.split("\t"); if (parts.length < 4) { return null; } for (int i = 0; i < parts.length; i++) { parts[i] = parts[i].trim(); } return new PageView(parts[0], Integer.parseInt(parts[1]), Integer.parseInt(parts[2]), Integer.parseInt(parts[3])); } PageView(String url, int status, int zipCode, int userID); @Override String toString(); static PageView fromString(String pv); Object getValue(Item field); final String url; final int status; final int zipCode; final int userID; }
@Test public void testFromString() { String pvString = "http: PageView pageView = PageView.fromString(pvString); assertThat(pageView.url).isEqualTo("http: assertThat(pageView.status).isEqualTo(200); assertThat(pageView.zipCode).isEqualTo(100000); assertThat(pageView.userID).isEqualTo(1); assertThat(pageView.toString()).isEqualTo(pvString); }