DockerFileFactory { @NotNull public VirtualFile newInstance(@NotNull String href) { return newInstance(href, NAME, PATH); } @Inject  DockerFileFactory(ProjectServiceClient projectServiceClient,
                             DtoFactory dtoFactory,
                             AppContext appContext); @NotNull VirtualFile newInstance(@NotNull String href); @NotNull VirtualFile newInstance(@NotNull String href, @NotNull String name, @NotNull String path); static final String NAME; static final String PATH; static final String TYPE; }
@Test(expected = IllegalStateException.class) public void illegalStateExceptionShouldBeThrownWhenCurrentProjectIsNull() throws Exception { when(appContext.getCurrentProject()).thenReturn(null); factory.newInstance(SOME_TEXT); }
@Test public void dockerFileShouldBeCreated() throws Exception { VirtualFile fileNode = factory.newInstance(SOME_TEXT); verify(dtoFactory).createDto(Link.class); verify(link).withHref(SOME_TEXT); verify(link).withRel(GET_CONTENT); verify(dtoFactory).createDto(ItemReference.class); verify(itemReference).withName(NAME); verify(itemReference).withPath(PATH); verify(itemReference).withMediaType(TYPE); verify(itemReference).withLinks(linkListCaptor.capture()); List<Link> links = linkListCaptor.getValue(); assertThat(links.get(0), equalTo(link)); assertThat(fileNode, notNullValue()); assertThat(fileNode, instanceOf(DockerFile.class)); }