public void testListAvailableFormTemplateInfos() throws Exception {
    String clientAccountId = clientSecurity1.getPublicKeyString();
    Vector emptyResponse = server.listAvailableFormTemplateInfos(clientAccountId);
    assertEquals("Already has forms?", 0, emptyResponse.size());

    ServerBulletinStore store = coreServer.getStore();
    MartusCrypto security = server.getSecurity();
    byte[] fakeTemplateData = new byte[] {1, 2, 3, 4, 5};
    String invalidBase64Template = StreamableBase64.encode(fakeTemplateData);
    try {
      ServerForClients.saveBase64FormTemplate(
          store, clientAccountId, invalidBase64Template, security, logger);
      fail("Should have thrown saving invalid template");
    } catch (FormTemplateParsingException ignoreExpected) {
    }

    createAndSaveSampleTemplate(store, clientAccountId, "First", security);
    createAndSaveSampleTemplate(store, clientAccountId, "Second", security);
    Vector storedTemplates = store.getListOfFormTemplatesForAccount(clientAccountId);
    assertEquals(2, storedTemplates.size());
    TemplateInfoForMirroring storedInfo1 =
        new TemplateInfoForMirroring((File) storedTemplates.get(0));
    TemplateInfoForMirroring storedInfo2 =
        new TemplateInfoForMirroring((File) storedTemplates.get(1));

    Vector resultVector = server.listAvailableFormTemplateInfos(clientAccountId);
    assertEquals("Wrong count?", 2, resultVector.size());
    TemplateInfoForMirroring gotInfo1 = new TemplateInfoForMirroring((String) resultVector.get(0));
    TemplateInfoForMirroring gotInfo2 = new TemplateInfoForMirroring((String) resultVector.get(1));

    assertEquals(storedInfo1, gotInfo1);
    assertEquals(storedInfo2, gotInfo2);
    assertTrue("Wrong order?", gotInfo1.asString().compareTo(gotInfo2.asString()) < 0);
  }
  public void testGetFormTemplate() throws Exception {
    ServerBulletinStore store = coreServer.getStore();
    String clientAccountId = clientSecurity1.getPublicKeyString();
    MartusCrypto security = server.getSecurity();

    String formTitle = "First";
    createAndSaveSampleTemplate(store, clientAccountId, formTitle, security);
    String formFilename = FormTemplate.calculateFileNameFromString(formTitle);
    File templateFile = store.getFormTemplateFileFromAccount(clientAccountId, formFilename);
    String templateFilename = templateFile.getName();
    Vector templateVector = server.getFormTemplate(clientAccountId, templateFilename);
    assertEquals(
        "templateVector1 doesn't have the required one element?", 1, templateVector.size());
    String gotTemplateBase64 = (String) templateVector.get(0);
    String savedTemplateBase64 = StreamableBase64.readAllAndEncodeBase64(templateFile);
    assertEquals(savedTemplateBase64, gotTemplateBase64);
  }