Tabnine Logo
FSMenuService
Code IndexAdd Tabnine to your IDE (free)

How to use
FSMenuService
in
org.jbpm.form.builder.services.impl.fs

Best Java code snippets using org.jbpm.form.builder.services.impl.fs.FSMenuService (Showing top 20 results out of 315)

origin: org.jbpm/jbpm-form-services

@Override
public List<MenuOptionDescription> listOptions() throws MenuServiceException {
  Gson gson = new Gson();
  List<MenuOptionDescription> retval = new ArrayList<MenuOptionDescription>();
  try {
    URL url = asURL("/menuOptions.json");
    retval = gson.fromJson(createReader(url), new TypeToken<List<MenuOptionDescription>>(){}.getType());
  } catch (URISyntaxException e) {
    throw new MenuServiceException("Problem finding menu options json file", e); 
  } catch (FileNotFoundException e) {
    throw new MenuServiceException("No menu options json file found", e);
  } catch (Exception e) {
    throw new MenuServiceException("Unexpected error", e);
  }
  return retval;
}

origin: org.jbpm/form-services

@Override
public void saveMenuItem(String groupName, MenuItemDescription item) throws MenuServiceException {
  Map<String, List<MenuItemDescription>> items = listMenuItems();
  addToMap(groupName, item, items);
  writeMenuItems(items);
}

origin: org.jbpm/jbpm-form-services

@Override
public void deleteMenuItem(String groupName, MenuItemDescription item) throws MenuServiceException {
  Map<String, List<MenuItemDescription>> items = listMenuItems();
  removeFromMap(groupName, item, items);
  writeMenuItems(items);
}
origin: org.jbpm/form-services

private void writeMenuItems(Map<String, List<MenuItemDescription>> items) throws MenuServiceException {
  try {
    FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
    String json = encoder.encodeMenuItemsMap(items);
    URL url = asURL("/menuItems.json");
    writeToURL(url, json);
  } catch (FormEncodingException e) {
    throw new MenuServiceException("Problem transforming menu items to json", e);
  } catch (URISyntaxException e) {
    throw new MenuServiceException("Problem finding menu items json file", e);
  } catch (FileNotFoundException e) {
    throw new MenuServiceException("No menu items json file found", e);
  } catch (IOException e) {
    throw new MenuServiceException("Problem writing menu items json file", e);
  } catch (Exception e) {
    throw new MenuServiceException("Unexpected error", e);
  }
}
origin: org.jbpm/jbpm-form-services

@Override
public Map<String, List<MenuItemDescription>> listMenuItems() throws MenuServiceException {
  Map<String, List<MenuItemDescription>> retval = null;
  try {
    FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
    URL url = asURL("/menuItems.json");
    String json = readURL(url);
    retval = decoder.decodeMenuItemsMap(json);
  } catch (FormEncodingException e) {
    throw new MenuServiceException("Problem parsing menu items json file", e);
  } catch (URISyntaxException e) {
    throw new MenuServiceException("Problem finding menu items json file", e);
  } catch (FileNotFoundException e) {
    throw new MenuServiceException("No menu items json file found", e);
  } catch (IOException e) {
    throw new MenuServiceException("Problem reading menu items json file", e);
  } catch (Exception e) {
    throw new MenuServiceException("Unexpected error", e);
  }
  return retval;
}
origin: org.jbpm/form-services

@Test
public void testListItemsOK() throws Exception {
  FSMenuService service = new FSMenuService();
  Map<String, List<MenuItemDescription>> items = service.listMenuItems();
  assertNotNull("items shouldn't be null", items);
  assertFalse("items shouldn't be empty", items.isEmpty());
  for (String key : items.keySet()) {
    assertNotNull("items of key " + key + " shouldn't be null", items.get(key));
    assertFalse("items of key " + key + " shouldn't be empty", items.get(key).isEmpty());
  }
}
@Test
origin: org.jbpm/jbpm-form-services

private void abstractTestListItemsProblem(final Class<?> exceptionType) throws Exception {
  FSMenuService service = createMockedService(exceptionType);
  try {
    service.listMenuItems();
    fail("listOptions shouldn't succeed");
  } catch (MenuServiceException e) {
    assertNotNull("e shouldn't be null", e);
    Throwable cause = e.getCause();
    assertNotNull("cause shouldn't be null", cause);
    assertTrue("cause should be a " + exceptionType.getName(), cause.getClass().equals(exceptionType));
  }
}
@Test
origin: org.jbpm/jbpm-form-services

@Test
public void testGetFormBuilderProperties() throws Exception {
  FSMenuService service = new FSMenuService();
  Map<String, String> props = service.getFormBuilderProperties();
  assertNotNull("props shouldn't be null", props);
  assertFalse("props shouldn't be empty", props.isEmpty());
}

origin: org.jbpm/jbpm-form-services

@Test
public void testListOptionsOK() throws Exception {
  FSMenuService service = new FSMenuService();
  List<MenuOptionDescription> options = service.listOptions();
  assertNotNull("options shouldn't be null", options);
  assertFalse("options shouldn't be empty", options.isEmpty());
}
@Test
origin: org.jbpm/jbpm-form-services

  @Override
  protected void writeToURL(URL url, String json) throws FileNotFoundException, IOException {
    if (exceptionType != null) {
      if (exceptionType.equals(FileNotFoundException.class)) throw new FileNotFoundException(url.toExternalForm());
      if (exceptionType.equals(IOException.class)) throw new IOException(url.toExternalForm());
      throw new NullPointerException();
    }
    super.writeToURL(url, json);
  }
};
origin: org.jbpm/jbpm-form-services

@Override 
protected URL asURL(String path) throws URISyntaxException {
  if (exceptionType != null && exceptionType.equals(URISyntaxException.class)) throw new URISyntaxException(path, "mocking");
  return super.asURL(path);
}
@Override 
origin: org.jbpm/jbpm-form-services

@Override 
protected Reader createReader(URL url) throws FileNotFoundException, IOException {
  if (exceptionType != null) {
    if (exceptionType.equals(FileNotFoundException.class)) throw new FileNotFoundException(url.toExternalForm());
    if (exceptionType.equals(IOException.class)) throw new IOException(url.toExternalForm());
    throw new NullPointerException();
  }
  return super.createReader(url);
}
@Override
origin: org.jbpm/form-services

@Test
public void testListValidationsOK() throws Exception {
  FSMenuService service = new FSMenuService();
  List<ValidationDescription> validations = service.listValidations();
  assertNotNull("validations shouldn't be null", validations);
  assertFalse("validations should'nt be empty", validations.isEmpty());
  for (ValidationDescription desc : validations) {
    assertNotNull("validations shouldn't contain null elements", desc);
    assertNotNull("validation className shouldn't be null", desc.getClassName());
    assertFalse("validation className shouldn't be empty", "".equals(desc.getClassName()));
  }
}

origin: org.jbpm/jbpm-form-services

@Override
protected String readURL(URL url) throws FileNotFoundException, IOException {
  if (exceptionType != null) {
    if (exceptionType.equals(FileNotFoundException.class)) throw new FileNotFoundException(url.toExternalForm());
    if (exceptionType.equals(IOException.class)) throw new IOException(url.toExternalForm());
    throw new NullPointerException();
  }
  return super.readURL(url);
}
@Override
origin: org.jbpm/form-services

private void abstractTestListOptionsProblem(final Class<?> exceptionType) throws Exception {
  FSMenuService service = createMockedService(exceptionType);
  try {
    service.listOptions();
    fail("listOptions shouldn't succeed");
  } catch (MenuServiceException e) {
    assertNotNull("e shouldn't be null", e);
    Throwable cause = e.getCause();
    assertNotNull("cause shouldn't be null", cause);
    assertTrue("cause should be a " + exceptionType.getName(), cause.getClass().equals(exceptionType));
  }
}
origin: org.jbpm/form-services

private void abstractTestListValidationsProblem(final Class<?> exceptionType) throws Exception {
  FSMenuService service = createMockedService(exceptionType);
  try {
    service.listValidations();
    fail("listOptions shouldn't succeed");
  } catch (MenuServiceException e) {
    assertNotNull("e shouldn't be null", e);
    Throwable cause = e.getCause();
    assertNotNull("cause shouldn't be null", cause);
    assertTrue("cause should be a " + exceptionType.getName(), cause.getClass().equals(exceptionType));
  }
}
@Test
origin: org.jbpm/form-services

@Override
public void deleteMenuItem(String groupName, MenuItemDescription item) throws MenuServiceException {
  Map<String, List<MenuItemDescription>> items = listMenuItems();
  removeFromMap(groupName, item, items);
  writeMenuItems(items);
}
origin: org.jbpm/jbpm-form-services

private void writeMenuItems(Map<String, List<MenuItemDescription>> items) throws MenuServiceException {
  try {
    FormRepresentationEncoder encoder = FormEncodingFactory.getEncoder();
    String json = encoder.encodeMenuItemsMap(items);
    URL url = asURL("/menuItems.json");
    writeToURL(url, json);
  } catch (FormEncodingException e) {
    throw new MenuServiceException("Problem transforming menu items to json", e);
  } catch (URISyntaxException e) {
    throw new MenuServiceException("Problem finding menu items json file", e);
  } catch (FileNotFoundException e) {
    throw new MenuServiceException("No menu items json file found", e);
  } catch (IOException e) {
    throw new MenuServiceException("Problem writing menu items json file", e);
  } catch (Exception e) {
    throw new MenuServiceException("Unexpected error", e);
  }
}
origin: org.jbpm/form-services

@Override
public Map<String, List<MenuItemDescription>> listMenuItems() throws MenuServiceException {
  Map<String, List<MenuItemDescription>> retval = null;
  try {
    FormRepresentationDecoder decoder = FormEncodingFactory.getDecoder();
    URL url = asURL("/menuItems.json");
    String json = readURL(url);
    retval = decoder.decodeMenuItemsMap(json);
  } catch (FormEncodingException e) {
    throw new MenuServiceException("Problem parsing menu items json file", e);
  } catch (URISyntaxException e) {
    throw new MenuServiceException("Problem finding menu items json file", e);
  } catch (FileNotFoundException e) {
    throw new MenuServiceException("No menu items json file found", e);
  } catch (IOException e) {
    throw new MenuServiceException("Problem reading menu items json file", e);
  } catch (Exception e) {
    throw new MenuServiceException("Unexpected error", e);
  }
  return retval;
}
origin: org.jbpm/jbpm-form-services

@Test
public void testListItemsOK() throws Exception {
  FSMenuService service = new FSMenuService();
  Map<String, List<MenuItemDescription>> items = service.listMenuItems();
  assertNotNull("items shouldn't be null", items);
  assertFalse("items shouldn't be empty", items.isEmpty());
  for (String key : items.keySet()) {
    assertNotNull("items of key " + key + " shouldn't be null", items.get(key));
    assertFalse("items of key " + key + " shouldn't be empty", items.get(key).isEmpty());
  }
}
@Test
org.jbpm.form.builder.services.impl.fsFSMenuService

Most used methods

  • asURL
  • createReader
  • listMenuItems
  • readURL
  • writeToURL
  • <init>
  • addToMap
  • getFormBuilderProperties
  • listOptions
  • listValidations
  • removeFromMap
  • saveMenuItem
  • removeFromMap,
  • saveMenuItem,
  • writeMenuItems

Popular in Java

  • Finding current android device location
  • compareTo (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now