@Test public void testReadTemplateShouldReturnWithResourceWhenStubResourceHolderDoesntContainTemplateYet() throws IOException { given(stubResourceHolder.getTemplates()).willReturn(templatesMap); given(templatesMap.containsKey(RESOURCE_NAME)).willReturn(false); given(fileFactory.createFile(Mockito.anyString())).willReturn(file); given(fileUtils.getFileAsByteArray(file)).willReturn(RESOURCE_NAME.getBytes()); byte[] actual = underTest.readTemplate(RESOURCE_NAME); Mockito.verify(stubResourceHolder).addTemplate(RESOURCE_NAME, actual); assertEquals(actual, RESOURCE_NAME.getBytes()); }
public byte[] readTemplate(final String templatesName) { byte[] result; Map<String, byte[]> templatesMap = resourceHolder.getTemplates(); if (templatesMap.containsKey(templatesName)) { result = templatesMap.get(templatesName); } else { result = readTemplateFromFileSystem(templatesName); resourceHolder.addTemplate(templatesName, result); } return result; }
TemplateFileReader { public byte[] readTemplate(final String templatesName) { byte[] result; Map<String, byte[]> templatesMap = resourceHolder.getTemplates(); if (templatesMap.containsKey(templatesName)) { result = templatesMap.get(templatesName); } else { result = readTemplateFromFileSystem(templatesName); resourceHolder.addTemplate(templatesName, result); } return result; } }
TemplateFileReader { public byte[] readTemplate(final String templatesName) { byte[] result; Map<String, byte[]> templatesMap = resourceHolder.getTemplates(); if (templatesMap.containsKey(templatesName)) { result = templatesMap.get(templatesName); } else { result = readTemplateFromFileSystem(templatesName); resourceHolder.addTemplate(templatesName, result); } return result; }  }
TemplateFileReader { public byte[] readTemplate(final String templatesName) { byte[] result; Map<String, byte[]> templatesMap = resourceHolder.getTemplates(); if (templatesMap.containsKey(templatesName)) { result = templatesMap.get(templatesName); } else { result = readTemplateFromFileSystem(templatesName); resourceHolder.addTemplate(templatesName, result); } return result; }  byte[] readTemplate(final String templatesName); }
TemplateFileReader { public byte[] readTemplate(final String templatesName) { byte[] result; Map<String, byte[]> templatesMap = resourceHolder.getTemplates(); if (templatesMap.containsKey(templatesName)) { result = templatesMap.get(templatesName); } else { result = readTemplateFromFileSystem(templatesName); resourceHolder.addTemplate(templatesName, result); } return result; }  byte[] readTemplate(final String templatesName);  }