Codota Logo
UseCasePart
Code IndexAdd Codota to your IDE (free)

How to use
UseCasePart
in
org.requirementsascode

Best Java code snippets using org.requirementsascode.UseCasePart (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: bertilmuth/requirementsascode

public Model buildWith(ModelBuilder modelBuilder) {
Model model = modelBuilder.useCase("Get greeted")
  .basicFlow()
    .step("S1").system(this::greetsUser)
  .build();
return model;
}
origin: bertilmuth/requirementsascode

/**
 * Creates a new flow in the current use case.
 *
 * @param flowName
 *            the name of the flow to be created.
 * @return the newly created flow part
 * @throws ElementAlreadyInModel
 *             if a flow with the specified name already exists in the use case
 */
public FlowPart flow(String flowName) {
Objects.requireNonNull(flowName);
FlowPart useCaseFlowPart = stepPart.getUseCasePart().flow(flowName);
return useCaseFlowPart;
}
origin: bertilmuth/requirementsascode

public Model build() {
  return UseCasePart.this.build();
}
origin: bertilmuth/requirementsascode

@Test
public void createsSingleStepWithNoPreviousStep() {
UseCasePart useCasePart = modelBuilder.useCase(USE_CASE);
useCasePart.basicFlow()
  .step(SYSTEM_DISPLAYS_TEXT).system(displaysConstantText());
Collection<Step> steps = useCasePart.getUseCase().getSteps();
assertEquals(1, steps.size());
Optional<FlowStep> previousStep = ((FlowStep) steps.iterator().next()).getPreviousStepInFlow();
assertFalse(previousStep.isPresent());
}

origin: bertilmuth/requirementsascode

@Test
public void continuesWithoutAlternativeAtFirstStepCalledFromFirstStepOfAlternativeFlowWithoutEvent() {		
  Model model = modelBuilder
    .useCase(USE_CASE)
      .basicFlow()
        .step(CUSTOMER_ENTERS_TEXT).user(EntersText.class).system(displaysEnteredText())
        .step(CUSTOMER_ENTERS_TEXT_AGAIN).user(EntersText.class).system(displaysEnteredText())
        .step(CUSTOMER_ENTERS_NUMBER).user(EntersNumber.class).system(displaysEnteredNumber())		
      .flow(ALTERNATIVE_FLOW).insteadOf(CUSTOMER_ENTERS_TEXT)
        .step(CONTINUE).continuesWithoutAlternativeAt(CUSTOMER_ENTERS_TEXT)
    .build();
  
  modelRunner.run(model).reactTo(entersText(), entersText());
     assertRecordedStepNames(CONTINUE, CUSTOMER_ENTERS_TEXT, CUSTOMER_ENTERS_TEXT_AGAIN);
}

origin: bertilmuth/requirementsascode

public Model buildWith(ModelBuilder modelBuilder) {
Model model = modelBuilder.useCase("Get greeted")
  .basicFlow()
    .step("S1").system(this::promptsUserToEnterFirstName)
    .step("S2").user(ENTERS_FIRST_NAME).system(this::savesFirstName)
    .step("S3").system(this::promptsUserToEnterAge)
    .step("S4").user(ENTERS_AGE).system(this::savesAge)
    .step("S5").system(this::greetsUserWithFirstNameAndAge)
    .step("S6").system(this::stops)
  .flow("Handle out-of-bounds age").insteadOf("S5").condition(this::ageIsOutOfBounds)
    .step("S5a_1").system(this::informsUserAboutOutOfBoundsAge)
    .step("S5a_2").continuesAt("S3")
  .flow("Handle non-numerical age").insteadOf("S5")
    .step("S5b_1").on(NON_NUMERICAL_AGE).system(this::informsUserAboutNonNumericalAge)
    .step("S5b_2").continuesAt("S3")
  .build();
return model;
}
origin: bertilmuth/requirementsascode

modelBuilder
 .useCase("Included use case")
  .basicFlow()
   .step("Included step").system(promptsUserToEnterName())
 .useCase("Get greeted")
  .basicFlow()
   .step("S1").system(promptsUserToEnterName())
   .step("S2").user(entersName()).system(greetsUser())
   .step("S4a_1").system(blowsUp())
   .step("S4a_2").continuesAt("S1")
  .flow("Alternative flow B").after("S3")
   .step("S4b_1").continuesAfter("S2")
  .flow("Alternative flow C").condition(thereIsNoAlternative())
   .step("S5a").continuesWithoutAlternativeAt("S4")
  .flow("Alternative flow D").insteadOf("S4").condition(thereIsNoAlternative())
   .step("S4c_1").includesUseCase("Included use case")
   .step("S4c_2").continuesAt("S1")
  .flow("EX").anytime()
    .step("EX1").on(Exception.class).system(logsException())
 .build();    
origin: bertilmuth/requirementsascode

/**
 * Creates a handler for events or exceptions of the specified type.
 * <p>
 * Internally, a default use case ("Handles events") is created in the model.
 * </p>
 * 
 * @param eventOrExceptionClass the specified event / exception class
 * @param <T> the type of events/exceptions
 * @return a part of the builder used to create the event handler (the "system reaction")
 */
public <T> FlowlessUserPart<T> on(Class<T> eventOrExceptionClass) {
FlowlessUserPart<T> on = useCase(HANDLES_EVENTS).on(eventOrExceptionClass);
return on;
}

origin: bertilmuth/requirementsascode

@Test
public void createsSingleStepThatHandlesUserCommandWithUseCaseButWithoutFlow() {
UseCasePart useCasePart = modelBuilder.useCase(USE_CASE);
Model model = 
  useCasePart
    .on(EntersText.class).system(displaysEnteredText())
  .build();
UseCase useCase = useCasePart.getUseCase();
Collection<Step> steps = useCase.getSteps();
assertEquals(1, steps.size());
Step step = steps.iterator().next();
assertEquals("S1", step.getName());
assertEquals(USE_CASE, step.getUseCase().getName());
assertEquals(model.getSystemActor(), step.getActors()[0]);
}

origin: bertilmuth/requirementsascode

public <T> FlowlessUserPart<T> on(Class<T> eventOrExceptionClass) {
ConditionPart conditionPart = condition(null);
FlowlessUserPart<T> flowlessUserPart = conditionPart.on(eventOrExceptionClass);
return flowlessUserPart;
}
origin: bertilmuth/requirementsascode

FlowPart(Flow flow, UseCasePart useCasePart) {
this.flow = flow;
this.useCasePart = useCasePart;
this.useCase = useCasePart.getUseCase();
}
origin: bertilmuth/requirementsascode

@Test
public void continuesAfterSecondStepCalledFromFirstStepOfAlternativeFlowWithoutEvent() {		
  Model model = modelBuilder
    .useCase(USE_CASE)
      .basicFlow()
        .step(CUSTOMER_ENTERS_TEXT).user(EntersText.class).system(displaysEnteredText())
        .step(CUSTOMER_ENTERS_TEXT_AGAIN).user(EntersText.class).system(displaysEnteredText())
        .step(CUSTOMER_ENTERS_NUMBER).user(EntersNumber.class).system(displaysEnteredNumber())		
      .flow(ALTERNATIVE_FLOW).insteadOf(CUSTOMER_ENTERS_TEXT_AGAIN)
        .step(CONTINUE).continuesAfter(CUSTOMER_ENTERS_TEXT_AGAIN)
    .build();
  
  modelRunner.run(model).reactTo(entersText(), entersNumber());
     assertRecordedStepNames(CUSTOMER_ENTERS_TEXT, CONTINUE, CUSTOMER_ENTERS_NUMBER);
}

origin: bertilmuth/requirementsascode

@Test
public void createsTwoStepsAndCheckIfTheyExistInUseCaseByName() {
UseCasePart useCasePart = modelBuilder.useCase(USE_CASE);
useCasePart.basicFlow()
  .step(SYSTEM_DISPLAYS_TEXT).system(displaysConstantText())
  .step(SYSTEM_DISPLAYS_TEXT_AGAIN).system(displaysConstantText());
Collection<Step> steps = useCasePart.getUseCase().getSteps();
assertEquals(2, steps.size());
boolean firstUseCaseStepExists = useCasePart.getUseCase().hasStep(SYSTEM_DISPLAYS_TEXT);
boolean secondUseCaseStepExists = useCasePart.getUseCase().hasStep(SYSTEM_DISPLAYS_TEXT_AGAIN);
assertTrue(firstUseCaseStepExists);
assertTrue(secondUseCaseStepExists);
}
origin: bertilmuth/requirementsascode

public Model buildWith(ModelBuilder modelBuilder) {
normalUser = modelBuilder.actor("Normal User");
anonymousUser = modelBuilder.actor("Anonymous User");
Model model = modelBuilder.useCase("Get greeted")
  .basicFlow()
    .step("S1").as(normalUser).system(this::promptsUserToEnterFirstName)
    .step("S2").as(normalUser).user(ENTERS_FIRST_NAME).system(this::savesFirstName)
    .step("S3").as(normalUser, anonymousUser).system(this::promptsUserToEnterAge)
    .step("S4").as(normalUser, anonymousUser).user(ENTERS_AGE).system(this::savesAge)
    .step("S5").as(normalUser).system(this::greetsUserWithFirstName)
    .step("S6").as(normalUser, anonymousUser).system(this::greetsUserWithAge)
    .step("S7").as(normalUser, anonymousUser).system(this::stops)
  .flow("Handle out-of-bounds age").insteadOf("S5").condition(this::ageIsOutOfBounds)
    .step("S5a_1").system(this::informsUserAboutOutOfBoundsAge)
    .step("S5a_2").continuesAt("S3")
  .flow("Handle non-numerical age").insteadOf("S5")
    .step("S5b_1").on(NON_NUMERICAL_AGE).system(this::informsUserAboutNonNumericalAge)
    .step("S5b_2").continuesAt("S3")
  .flow("Anonymous greeted with age only").insteadOf("S5").condition(this::ageIsOk)
    .step("S5c_1").as(anonymousUser).continuesAt("S6")
  .flow("Anonymous does not enter name").insteadOf("S1")
    .step("S1a_1").as(anonymousUser).continuesAt("S3")
  .build();
return model;
}
origin: bertilmuth/requirementsascode

@Test
public void twoFlowlessStepsReactWhenConditionIsTrueInSecondStepWithoutEvent() {
Model model = modelBuilder.useCase(USE_CASE)
  .on(EntersText.class).system(displaysEnteredText())
  .condition(() -> modelRunner.getLatestStep().isPresent() && modelRunner.getLatestStep().get().getEventClass().equals(EntersText.class)).system(displaysConstantText())
.build();
modelRunner.run(model).reactTo(entersText());
assertEquals(ModelRunner.class, modelRunner.getLatestStep().get().getEventClass());
}

origin: bertilmuth/requirementsascode

@Test
public void createsTwoStepsWithoutFlow() {
UseCasePart useCasePart = modelBuilder.useCase(USE_CASE);
useCasePart
  .on(EntersText.class).system(displaysEnteredText())
  .on(EntersNumber.class).system(displaysEnteredNumber())
.build();
Collection<Step> steps = useCasePart.getUseCase().getSteps();
assertEquals(2, steps.size());
Iterator<Step> stepIt = steps.iterator();
Step step = stepIt.next();
assertEquals("S1", step.getName());
assertEquals(USE_CASE, step.getUseCase().getName());
step = stepIt.next();
assertEquals("S2", step.getName());
assertEquals(USE_CASE, step.getUseCase().getName());
}
origin: bertilmuth/requirementsascode

/**
 * Only if the specified condition is true, the event is handled.
 *
 * @param condition
 *            the condition that constrains when the event is handled
 * @return a part of the builder used to define the event's class
 */
public ConditionPart condition(Condition condition) {
return useCase(HANDLES_EVENTS).condition(condition);
}
origin: bertilmuth/requirementsascode

/**
 * Start the "happy day scenario" where all is fine and dandy.
 * 
 * @return the flow part to create the steps of the basic flow.
 */
public FlowPart basicFlow() {
Flow useCaseFlow = getUseCase().getBasicFlow();
return new FlowPart(useCaseFlow, this);
}
origin: bertilmuth/requirementsascode

public Model buildWith(ModelBuilder modelBuilder) {
Model model = modelBuilder.useCase("Get greeted")
  .basicFlow()
    .step("S1").system(this::greetsUser)
    .step("S2").system(this::printsHooray).reactWhile(this::lessThanThreeHooraysHaveBeenPrinted)
  .build();
return model;
}
origin: bertilmuth/requirementsascode

@Test
public void continuesAtThirdStepCalledFromFirstStepOfAlternativeFlowWithoutEvent() {		
  Model model = modelBuilder
    .useCase(USE_CASE)
      .basicFlow()
        .step(CUSTOMER_ENTERS_TEXT).user(EntersText.class).system(displaysEnteredText())
        .step(CUSTOMER_ENTERS_TEXT_AGAIN).user(EntersText.class).system(displaysEnteredText())
        .step(CUSTOMER_ENTERS_NUMBER).user(EntersNumber.class).system(displaysEnteredNumber())		
      .flow(ALTERNATIVE_FLOW).insteadOf(CUSTOMER_ENTERS_TEXT_AGAIN)
        .step(CONTINUE).continuesAt(CUSTOMER_ENTERS_NUMBER)
    .build();
  
  modelRunner.run(model).reactTo(entersText(), entersNumber());
     assertRecordedStepNames(CUSTOMER_ENTERS_TEXT, CONTINUE,
    CUSTOMER_ENTERS_NUMBER);
}

org.requirementsascodeUseCasePart

Javadoc

Part used by the ModelBuilder to build a Model.

Most used methods

  • basicFlow
    Start the "happy day scenario" where all is fine and dandy.
  • flow
    Start a flow with the specified name.
  • build
    Returns the model that has been built.
  • condition
  • getUseCase
  • on
  • <init>
  • getModelBuilder

Popular in Java

  • Start an intent from android
  • setContentView (Activity)
  • startActivity (Activity)
  • getContentResolver (Context)
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now