@Test public void testExecuteSuccessListNoMailResource() { createMailResource(); parameters = new ParameterMap(); org.glassfish.resources.mail.admin.cli.ListMailResources listCommand = habitat.getService(org.glassfish.resources.mail.admin.cli.ListMailResources.class); cr.getCommandInvocation("list-mail-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand); List<ActionReport.MessagePart> list = context.getActionReport().getTopMessagePart().getChildren(); assertEquals(origNum + 1, list.size()); origNum = origNum + 1; deleteMailResource(); parameters = new ParameterMap(); listCommand = habitat.getService(org.glassfish.resources.mail.admin.cli.ListMailResources.class); context = new AdminCommandContextImpl( LogDomains.getLogger(ListMailResourcesTest.class, LogDomains.ADMIN_LOGGER), new PropsFileActionReporter()); cr.getCommandInvocation("list-mail-resources", context.getActionReport(), adminSubject()).parameters(parameters).execute(listCommand); list = context.getActionReport().getTopMessagePart().getChildren(); if ((origNum - 1) == 0) { } else { assertEquals(origNum - 1, list.size()); } List<String> listStr = new ArrayList<String>(); for (MessagePart mp : list) { listStr.add(mp.getMessage()); } assertFalse(listStr.contains("mailresource")); assertEquals(ActionReport.ExitCode.SUCCESS, context.getActionReport().getActionExitCode()); }
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); try { List<String> list = new ArrayList<String>(); Collection<MailResource> mailResources = domain.getResources().getResources(MailResource.class); for (MailResource mailResource : mailResources) { if(bindableResourcesHelper.resourceExists(mailResource.getJndiName(), targetOperand)){ list.add(mailResource.getJndiName()); } } for (String jndiName : list) { final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(jndiName); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } catch (Exception e) { report.setMessage(localStrings.getLocalString( "list.mail.resources.failed", "Unable to list mail resources") + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); } }
ListMailResources implements AdminCommand { public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); try { List<String> list = new ArrayList<String>(); Collection<MailResource> mailResources = domain.getResources().getResources(MailResource.class); for (MailResource mailResource : mailResources) { if(bindableResourcesHelper.resourceExists(mailResource.getJndiName(), targetOperand)){ list.add(mailResource.getJndiName()); } } for (String jndiName : list) { final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(jndiName); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } catch (Exception e) { report.setMessage(localStrings.getLocalString( "list.mail.resources.failed", "Unable to list mail resources") + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); } } }
ListMailResources implements AdminCommand { public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); try { List<String> list = new ArrayList<String>(); Collection<MailResource> mailResources = domain.getResources().getResources(MailResource.class); for (MailResource mailResource : mailResources) { if(bindableResourcesHelper.resourceExists(mailResource.getJndiName(), targetOperand)){ list.add(mailResource.getJndiName()); } } for (String jndiName : list) { final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(jndiName); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } catch (Exception e) { report.setMessage(localStrings.getLocalString( "list.mail.resources.failed", "Unable to list mail resources") + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); } }  }
ListMailResources implements AdminCommand { public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); try { List<String> list = new ArrayList<String>(); Collection<MailResource> mailResources = domain.getResources().getResources(MailResource.class); for (MailResource mailResource : mailResources) { if(bindableResourcesHelper.resourceExists(mailResource.getJndiName(), targetOperand)){ list.add(mailResource.getJndiName()); } } for (String jndiName : list) { final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(jndiName); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } catch (Exception e) { report.setMessage(localStrings.getLocalString( "list.mail.resources.failed", "Unable to list mail resources") + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); } }  void execute(AdminCommandContext context); }
ListMailResources implements AdminCommand { public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); try { List<String> list = new ArrayList<String>(); Collection<MailResource> mailResources = domain.getResources().getResources(MailResource.class); for (MailResource mailResource : mailResources) { if(bindableResourcesHelper.resourceExists(mailResource.getJndiName(), targetOperand)){ list.add(mailResource.getJndiName()); } } for (String jndiName : list) { final ActionReport.MessagePart part = report.getTopMessagePart().addChild(); part.setMessage(jndiName); } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } catch (Exception e) { report.setMessage(localStrings.getLocalString( "list.mail.resources.failed", "Unable to list mail resources") + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); } }  void execute(AdminCommandContext context);  }