### Question:
AddArchetypeModalPresenter implements HasBusyIndicator { public void add() { final String archetypeGroupId = view.getArchetypeGroupId(); final String archetypeArtifactId = view.getArchetypeArtifactId(); final String archetypeVersion = view.getArchetypeVersion(); validateFields(archetypeGroupId, archetypeArtifactId, archetypeVersion, () -> { beginAddArchetype(); final GAV archetypeGAV = new GAV(archetypeGroupId.trim(), archetypeArtifactId.trim(), archetypeVersion.trim()); archetypeService.call(v -> { endAddArchetype(); hide(); }, addActionErrorCallback()).add(archetypeGAV); }); } @Inject  AddArchetypeModalPresenter(final View view,
                                      final TranslationService ts,
                                      final Caller<ArchetypeService> archetypeService,
                                      final BusyIndicatorView busyIndicatorView); @PostConstruct void postConstruct(); void show(); void hide(); void add(); void cancel(); @Override void showBusyIndicator(final String message); @Override void hideBusyIndicator();  }### Answer:
@Test public void addWhenInvalidGroupIdTest() { doReturn(null).when(view).getArchetypeGroupId(); doReturn(ARTIFACT_ID).when(view).getArchetypeArtifactId(); doReturn(VERSION).when(view).getArchetypeVersion(); presenter.add(); verify(view).clearErrors(); verify(view).showArchetypeGroupIdError(anyString()); verify(archetypeService, never()).add(any(GAV.class)); }
@Test public void addWhenInvalidArtifactIdTest() { doReturn(GROUP_ID).when(view).getArchetypeGroupId(); doReturn(null).when(view).getArchetypeArtifactId(); doReturn(VERSION).when(view).getArchetypeVersion(); presenter.add(); verify(view).clearErrors(); verify(view).showArchetypeArtifactIdError(anyString()); verify(archetypeService, never()).add(any(GAV.class)); }
@Test public void addWhenInvalidVersionIdTest() { doReturn(GROUP_ID).when(view).getArchetypeGroupId(); doReturn(ARTIFACT_ID).when(view).getArchetypeArtifactId(); doReturn(null).when(view).getArchetypeVersion(); presenter.add(); verify(view).clearErrors(); verify(view).showArchetypeVersionError(anyString()); verify(archetypeService, never()).add(any(GAV.class)); }
@Test public void addWhenAllFieldsInvalidTest() { doReturn(null).when(view).getArchetypeGroupId(); doReturn(null).when(view).getArchetypeArtifactId(); doReturn(null).when(view).getArchetypeVersion(); presenter.add(); verify(view).clearErrors(); verify(view).showArchetypeGroupIdError(anyString()); verify(view).showArchetypeArtifactIdError(anyString()); verify(view).showArchetypeVersionError(anyString()); verify(archetypeService, never()).add(any(GAV.class)); }