All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.toast.tk.runtime.block.VariableBlockBuilder Maven / Gradle / Ivy

Go to download

Toast Toolkit Runtime Module contains covers: - Test Source Adapters - Test Parsing - Test Execution - Test Report generation

The newest version!
package io.toast.tk.runtime.block;

import java.util.List;

import com.google.inject.Inject;

import io.toast.tk.dao.domain.impl.test.block.VariableBlock;
import io.toast.tk.dao.domain.impl.test.block.line.BlockLine;
import io.toast.tk.runtime.IActionItemRepository;

public class VariableBlockBuilder implements IBlockRunner {

	@Inject
	private IActionItemRepository objectRepository;

	@Override
	public void run(final VariableBlock block) {
		block.getBlockLines().forEach(this::putUserVariable);
	}

	private void putUserVariable(final BlockLine blockLine) {
		objectRepository.getUserVariables().put(getCellAt(0, blockLine), getCellAt(1, blockLine));
	}

	private static String getCellAt(
			final int index,
			final BlockLine blockLine
	) {
		final List cells = blockLine.getCells();
		if (index < 0 || index >= cells.size()) {
			return null;
		}
		return cells.get(index);
	}

	@Override
	public void setRepository(final IActionItemRepository objectRepository) {
		this.objectRepository = objectRepository;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy