### Question:
ServerGroup { public static ServerGroup parse(String asg) { int d1 = asg.indexOf('-'); int d2 = asg.indexOf('-', d1 + 1); int dN = asg.lastIndexOf('-'); if (dN < 0 || !isSequence(asg, dN)) { dN = asg.length(); } return new ServerGroup(asg, d1, d2, dN); } ServerGroup(String asg, int d1, int d2, int dN); static ServerGroup parse(String asg); String app(); String cluster(); String asg(); String stack(); String detail(); String shard1(); String shard2(); String sequence(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void parseApp() { String asg = "app"; ServerGroup expected = new ServerGroup(asg, -1, -1, asg.length()); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseAppStack() { String asg = "app-stack"; ServerGroup expected = new ServerGroup(asg, 3, -1, asg.length()); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseAppStackDetail() { String asg = "app-stack-detail"; ServerGroup expected = new ServerGroup(asg, 3, 9, asg.length()); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseAppStackDetails() { String asg = "app-stack-detail_1-detail_2"; ServerGroup expected = new ServerGroup(asg, 3, 9, asg.length()); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseAppDetail() { String asg = "app--detail"; ServerGroup expected = new ServerGroup(asg, 3, 4, asg.length()); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseAppSeq() { String asg = "app-v001"; ServerGroup expected = new ServerGroup(asg, 3, -1, asg.length() - 5); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseAppStackSeq() { String asg = "app-stack-v001"; ServerGroup expected = new ServerGroup(asg, 3, 9, asg.length() - 5); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseAppStackDetailSeq() { String asg = "app-stack-detail-v001"; ServerGroup expected = new ServerGroup(asg, 3, 9, asg.length() - 5); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseAppStackDetailsSeq() { String asg = "app-stack-detail_1-detail_2-v001"; ServerGroup expected = new ServerGroup(asg, 3, 9, asg.length() - 5); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseAppDetailSeq() { String asg = "app--detail-v001"; ServerGroup expected = new ServerGroup(asg, 3, 4, asg.length() - 5); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseEmptyApp() { String asg = "-v1698"; ServerGroup expected = new ServerGroup(asg, 0, -1, 0); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }
@Test public void parseEmptyString() { String asg = ""; ServerGroup expected = new ServerGroup(asg, -1, -1, 0); Assertions.assertEquals(expected, ServerGroup.parse(asg)); }