Package ru.aristar.jnuget.sources.push

Examples of ru.aristar.jnuget.sources.push.ModifyStrategy


        }
        @SuppressWarnings("unchecked")
        PackageSource<Nupkg> newSource = (PackageSource) object;
        newSource.setName(storageOptions.getStorageName());
        setObjectProperties(storageOptions.getProperties(), object);
        ModifyStrategy pushStrategy = createPushStrategy(storageOptions);
        newSource.setPushStrategy(pushStrategy);
        logger.info("Установлена стратегия фиксации");
        if (storageOptions.isIndexed()) {
            newSource = createIndexForStorage(
                    newSource,
View Full Code Here


     */
    protected ModifyStrategy createPushStrategy(StorageOptions storegeOptions) throws Exception {
        //Создание стратегии фиксации
        //TODO убрать настройки стратегии, оставить только разрешение/запрещение публикации
        logger.info("Инициализация стратегии фиксации и удаления");
        ModifyStrategy pushStrategy = new ModifyStrategy(storegeOptions.isCanPush(), storegeOptions.isCanDelete());
        //Триггеры BEFORE
        pushStrategy.getBeforePushTriggers().addAll(createTriggers(storegeOptions.getBeforeTriggersOptions(), BeforeTrigger.class));
        //Триггеры Afther
        pushStrategy.getAftherPushTriggers().addAll(createTriggers(storegeOptions.getAftherTriggersOptions(), AfterTrigger.class));
        logger.info("Стратегия создана");
        return pushStrategy;
    }
View Full Code Here

    protected abstract void processPushPackage(Nupkg nupkg) throws IOException;

    @Override
    public ModifyStrategy getPushStrategy() {
        if (strategy == null) {
            strategy = new ModifyStrategy(false);
        }
        return strategy;
    }
View Full Code Here

     * @return триггеры, выполняющиеся после вставки пакета
     */
    public List<Properties> getAftherTriggers() {
        List<Properties> triggerOptions = new ArrayList<>();
        if (packageSource != null && packageSource.getPushStrategy() != null) {
            ModifyStrategy pushStrategy = packageSource.getPushStrategy();
            final List<AfterTrigger> afterTriggers = pushStrategy.getAftherPushTriggers();
            for (int i = 0; i < afterTriggers.size(); i++) {
                AfterTrigger afterTrigger = afterTriggers.get(i);
                Properties properties = new Properties(format("Триггер {0}", i + 1));
                triggerOptions.add(properties);
                Property classProperty = new Property("triggerClass", "Имя класса триггера", afterTrigger.getClass().getName());
View Full Code Here

        File packageFolder = new File(testFolder, tempNupkgFile.getId());
        if (packageFolder.exists()) {
            FileUtils.deleteDirectory(packageFolder);
        }
        MavenStylePackageSource mavenStylePackageSource = new MavenStylePackageSource(testFolder);
        mavenStylePackageSource.setPushStrategy(new ModifyStrategy(true));
        mavenStylePackageSource.pushPackage(tempNupkgFile);
        //WHEN
        MavenNupkg result = mavenStylePackageSource.getPackage(tempNupkgFile.getId(), tempNupkgFile.getVersion());
        //THEN
        assertEquals("Идентификатор пакета", tempNupkgFile.getId(), result.getId());
View Full Code Here

     * @return триггеры, выполняющиеся перед вставкой пакета
     */
    public List<Properties> getBeforeTriggers() {
        List<Properties> triggerOtions = new ArrayList<>();
        if (packageSource != null && packageSource.getPushStrategy() != null) {
            ModifyStrategy pushStrategy = packageSource.getPushStrategy();
            final List<BeforeTrigger> beforeTriggers = pushStrategy.getBeforePushTriggers();
            for (int i = 0; i < beforeTriggers.size(); i++) {
                BeforeTrigger beforeTrigger = beforeTriggers.get(i);
                Properties properties = new Properties(format("Триггер {0}", i + 1));
                triggerOtions.add(properties);
                Property classProperty = new Property("triggerClass", "Имя класса триггера", beforeTrigger.getClass().getName());
View Full Code Here

        File packageFolder = new File(testFolder, tempNupkgFile.getId().toLowerCase());
        if (packageFolder.exists()) {
            FileUtils.deleteDirectory(packageFolder);
        }
        MavenStylePackageSource mavenStylePackageSource = new MavenStylePackageSource(testFolder);
        mavenStylePackageSource.setPushStrategy(new ModifyStrategy(true));
        //WHEN
        mavenStylePackageSource.pushPackage(tempNupkgFile);
        File versionFolder = new File(packageFolder, "2.5.9.10348");
        File hashFile = new File(versionFolder, MavenNupkg.HASH_FILE_NAME);
        File packageFile = new File(versionFolder, "NUnit.2.5.9.10348.nupkg");
View Full Code Here

        InputStream inputStream = this.getClass().getResourceAsStream("/NUnit.2.5.9.10348.nupkg");
        try (TempNupkgFile nupkgFile = new TempNupkgFile(inputStream)) {
            IndexedPackageSource packageSource = new IndexedPackageSource();
            ClassicPackageSource filePackageSource = new ClassicPackageSource(localTestFolder);
            packageSource.setUnderlyingSource(filePackageSource, true).join();
            packageSource.setPushStrategy(new ModifyStrategy(true));
            //WHEN
            packageSource.pushPackage(nupkgFile);
            //THEN
            Nupkg nupkg = packageSource.getPackage("NUnit", Version.parse("2.5.9.10348"));
            assertNotNull(nupkg);
View Full Code Here

        File tmpFolder = File.createTempFile("NotAllow", "NotAllow");
        File tmpTestFolder = new File(tmpFolder, "NotAllow");
        tmpTestFolder.mkdirs();
        try {
            ClassicPackageSource classicPackageSource = new ClassicPackageSource(tmpTestFolder);
            ModifyStrategy simplePushStrategy = new ModifyStrategy(false);
            classicPackageSource.setPushStrategy(simplePushStrategy);
            TempNupkgFile nupkgFile = new TempNupkgFile(this.getClass().getResourceAsStream("/NUnit.2.5.9.10348.nupkg"));
            //WHEN
            boolean success = classicPackageSource.pushPackage(nupkgFile);
            //THEN
View Full Code Here

     */
    @Test
    public void testProcessTrigger() throws IOException, NugetPushException {
        //GIVEN
        final ClassicPackageSource classicPackageSource = new ClassicPackageSource(testFolder);
        ModifyStrategy simplePushStrategy = new ModifyStrategy(true);
        classicPackageSource.setPushStrategy(simplePushStrategy);
        List<Nupkg> pushedPackages = new ArrayList<>();
        //Пакет
        final Nupkg nupkg = context.mock(Nupkg.class);
        Expectations expectations = new Expectations();
        expectations.atLeast(0).of(nupkg).getFileName();
        expectations.will(returnValue("NUnit.2.5.9.10348.nupkg"));
        expectations.atLeast(0).of(nupkg).getStream();
        expectations.will(returnValue(this.getClass().getResourceAsStream("/NUnit.2.5.9.10348.nupkg")));
        //Триггер
        final BeforeTrigger trigger = context.mock(BeforeTrigger.class);
        expectations.oneOf(trigger).doAction(nupkg, classicPackageSource);
        expectations.will(new CallBackAction(pushedPackages));

        context.checking(expectations);
        simplePushStrategy.getBeforePushTriggers().add(trigger);

        //WHEN
        classicPackageSource.pushPackage(nupkg);
        assertArrayEquals("Пакеты для которых вызывался триггер", new Nupkg[]{nupkg}, pushedPackages.toArray(new Nupkg[0]));

View Full Code Here

TOP

Related Classes of ru.aristar.jnuget.sources.push.ModifyStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.