Search in sources :

Example 21 with Archetype

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype in project kie-wb-common by kiegroup.

the class ArchetypeServiceImpl method finishAddArchetype.

private Archetype finishAddArchetype(final GAV templateGav, final File repositoryDirectory, final boolean internal) throws GitAPIException, MavenEmbedderException {
    final Repository repository = makeArchetypeAvailable(templateGav, repositoryDirectory);
    final Archetype archetype = new Archetype(repository.getAlias(), templateGav, new Date(), ArchetypeStatus.VALID, internal);
    archetypeConfigStorage.saveArchetype(archetype);
    LOGGER.info("Archetype {} successfully added.", templateGav);
    return archetype;
}
Also used : Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) Date(java.util.Date)

Example 22 with Archetype

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype in project kie-wb-common by kiegroup.

the class ArchetypeServiceImpl method updateArchetypeStatus.

private void updateArchetypeStatus(final String alias, final ArchetypeStatus status, final String message) {
    final Archetype archetype = archetypeConfigStorage.loadArchetype(alias);
    final Archetype updatedArchetype = new Archetype(archetype.getAlias(), archetype.getGav(), archetype.getCreatedDate(), status, message, archetype.isInternal());
    archetypeConfigStorage.saveArchetype(updatedArchetype);
}
Also used : Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype)

Example 23 with Archetype

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype in project kie-wb-common by kiegroup.

the class ArchetypeItemPresenterTest method setupWhenIsNotIncludedTest.

@Test
public void setupWhenIsNotIncludedTest() {
    final Archetype archetype = createArchetypeWithStatus(ArchetypeStatus.VALID);
    final ArchetypeItem archetypeItem = new ArchetypeItem(archetype, false, true);
    presenter.setup(archetypeItem, tablePresenter);
    verify(view).setIncluded(false);
}
Also used : Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) ArchetypeItem(org.kie.workbench.common.screens.archetype.mgmt.client.table.item.model.ArchetypeItem) Test(org.junit.Test)

Example 24 with Archetype

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype in project kie-wb-common by kiegroup.

the class ArchetypeItemPresenterTest method setIncludedWhenIsNotValidTest.

@Test
public void setIncludedWhenIsNotValidTest() {
    final Archetype archetype = createArchetypeWithStatus(ArchetypeStatus.INVALID);
    final ArchetypeItem archetypeItem = new ArchetypeItem(archetype, true, true);
    doReturn(true).when(tablePresenter).canMakeChanges();
    presenter.setup(archetypeItem, tablePresenter);
    presenter.setIncluded(true);
    verify(view, never()).checkIncluded(anyBoolean());
    verify(tablePresenter, never()).setSelected(any(), anyBoolean());
}
Also used : Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) ArchetypeItem(org.kie.workbench.common.screens.archetype.mgmt.client.table.item.model.ArchetypeItem) Test(org.junit.Test)

Example 25 with Archetype

use of org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype in project kie-wb-common by kiegroup.

the class ArchetypeItemPresenterTest method setupWhenAllEnabledTest.

@Test
public void setupWhenAllEnabledTest() {
    final Archetype archetype = createArchetypeWithStatus(ArchetypeStatus.VALID);
    final ArchetypeItem archetypeItem = new ArchetypeItem(archetype, true, true);
    doReturn(true).when(tablePresenter).isShowIncludeColumn();
    doReturn(true).when(tablePresenter).isShowStatusColumn();
    doReturn(true).when(tablePresenter).isShowDeleteAction();
    doReturn(true).when(tablePresenter).isShowValidateAction();
    presenter.setup(archetypeItem, tablePresenter);
    verify(view).init(presenter);
    verify(view).setIncluded(archetypeItem.isSelected());
    verify(view).setGroupId(archetype.getGav().getGroupId());
    verify(view).setArtifactId(archetype.getGav().getArtifactId());
    verify(view).setVersion(archetype.getGav().getVersion());
    verify(view).setCreatedDate(ArchetypeItemPresenter.DATE_FORMAT.format(archetype.getCreatedDate()));
    verify(view).showInclude(true);
    verify(view).showStatus(true);
    verify(view).showDeleteAction(true);
    verify(view).showValidateAction(true);
    verify(view).showDefaultBadge(true);
    verify(view).enableIncludeCheckbox(true);
    verify(view).enableSetDefault(true);
    verify(view).setDeleteCommand(any());
    verify(view).setDefaultBadgeTooltip(Mockito.<String>any());
}
Also used : Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) ArchetypeItem(org.kie.workbench.common.screens.archetype.mgmt.client.table.item.model.ArchetypeItem) Test(org.junit.Test)

Aggregations

Archetype (org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype)38 Test (org.junit.Test)31 Repository (org.guvnor.structure.repositories.Repository)14 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)13 ArrayList (java.util.ArrayList)8 ArchetypeItem (org.kie.workbench.common.screens.archetype.mgmt.client.table.item.model.ArchetypeItem)8 PaginatedArchetypeList (org.kie.workbench.common.screens.archetype.mgmt.shared.model.PaginatedArchetypeList)7 Path (org.uberfire.java.nio.file.Path)5 GAV (org.guvnor.common.services.project.model.GAV)3 POM (org.guvnor.common.services.project.model.POM)2 ArchetypeListUpdatedEvent (org.kie.workbench.common.screens.archetype.mgmt.shared.events.ArchetypeListUpdatedEvent)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 File (java.io.File)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1