/** * The coder shall be able to decode all stock mechs. * * @throws Exception */ @Test public void testDecodeAllStock() throws Exception { InputStream is = LoadoutCoderV2.class.getResourceAsStream("/resources/lsmlv2stock.txt"); Scanner sc = new Scanner(is); Base64 base64 = new Base64(); // [JENNER JR7-D(F)]=lsml://rQAD5AgQCAwOFAYQCAwIuipmzMO3aIExIyk9jt2DMA== while (sc.hasNextLine()) { String line = sc.nextLine(); Pattern pat = Pattern.compile("\\[([^\\]]*)\\]\\s*=\\s*lsml://(\\S*).*"); Matcher m = pat.matcher(line); m.matches(); ChassisBase chassi = ChassisDB.lookup(m.group(1)); String lsml = m.group(2); LoadoutStandard reference = new LoadoutStandard(chassi.getName()); LoadoutStandard decoded = cut.decode(base64.decode(lsml.toCharArray())); // Name is not encoded OperationStack stack = new OperationStack(0); stack.pushAndApply(new OpRename(decoded, null, reference.getName())); // Verify assertEquals(reference, decoded); } sc.close(); }
public Entry(Collection<ChassisBase> aCollection) { Iterator<ChassisBase> iterator = aCollection.iterator(); String series = iterator.next().getNameShort(); while (iterator.hasNext()) { series += ","; ChassisBase chassi = iterator.next(); series += chassi.getNameShort().split("-")[1]; } name = series; representant = aCollection.iterator().next(); }