### Question:
DefaultPageLayoutService implements PageLayoutService { @Override public PageLayout getPageLayoutByCode(String code) { return pageLayoutRepository.getByPageLayoutCode(code); } @Autowired  DefaultPageLayoutService(PageLayoutRepository pageLayoutRepository); @Override PageLayout getPageLayoutByCode(String code); @Override List<PageLayout> getAll(); @Override List<PageLayout> getAllUserSelectable();  }### Answer:
@Test public void getPageLayoutByCode() { expect(pageLayoutRepository.getByPageLayoutCode(VALID_LAYOUT_CODE)).andReturn(validPageLayout); replay(pageLayoutRepository); assertThat(pageLayoutService.getPageLayoutByCode(VALID_LAYOUT_CODE), sameInstance(validPageLayout)); verify(pageLayoutRepository); }
@Test public void getPageLayoutByCode_invalidPageLayout() { expect(pageLayoutRepository.getByPageLayoutCode(INVALID_LAYOUT_CODE)).andReturn(null); replay(pageLayoutRepository); assertThat(pageLayoutService.getPageLayoutByCode(INVALID_LAYOUT_CODE), is(nullValue())); verify(pageLayoutRepository); }