@Test public void setTemplateFileNameShouldLoadAndParseTheTemplate() { when(factory.create(any(InputStream.class))).thenReturn(template); model.setUseLocalTemplate(true); model.setLocalTemplateFileName("resources/eap6-basic-sti.json"); verify(factory).create(any(InputStream.class)); assertEquals(template, model.getSelectedTemplate()); }
@Override public void setTemplateFileName(String name) { try { uploadedTemplate = resourceFactory.create(createInputStream(name)); setTemplate(uploadedTemplate); } catch (FileNotFoundException e) { name = ""; setTemplate(null); throw new OpenShiftException(e, "Unable to find the file to upload"); } catch (ResourceFactoryException | ClassCastException e) { name = ""; setTemplate(null); throw e; } finally { firePropertyChange( PROPERTY_TEMPLATE_FILENAME, this.templateFilename, this.templateFilename = name); } }