이벤트 순서 작성

이벤트 순서에서 테스트 이벤트 세트를 정의합니다. 생성하는 이벤트는 이벤트 순서 파일에서 정의한 순서대로 서버로 전송됩니다.

시작하기 전에

엔티티 순서 파일을 작성하기 전에 테스트 클라이언트 프로젝트를 작성해야 합니다.

이 태스크 정보

이벤트 순서 파일에서 솔루션 BOM 프로젝트에 정의된 이벤트 인스턴스를 작성할 수 있습니다. 이벤트 순서 구문은 Intellirule 편집기에서 제어하며 비즈니스 규칙 언어를 기반으로 합니다. 변수를 사용하고 이벤트 데이터를 수정하며 이벤트 시간소인을 설정할 수 있는 특정 언어 구성을 사용할 수 있습니다.

이벤트 순서 파일의 모든 이벤트(.eseq)는 emit <event> 구성이나 emit <event>, time-stamped <date & time> 구성을 사용하여 정의해야 합니다. .eseq 파일에 지정된 이벤트 순서로 처리 순서를 판별합니다. 이벤트 시간소인은 이벤트가 발생하는 시간을 표시합니다. 예를 들어, .eseq 파일에 다음 세 개의 이벤트가 있는 경우:

  • event1의 시간소인 3/24/2015
  • event2의 시간소인 3/25/2015
  • event3의 시간소인 3/22/2015

처리되는 이벤트 순서는 해당 시간소인과 관계 없이 event1, event2, event3입니다. event3에는 event2 및 event1보다 빠른 시간소인이 있으므로 이동 시 이벤트가 지연되어 순서대로 도착하지 못한 것으로 해석할 수 있습니다. 테스트는 이벤트 순서의 첫 번째 시간소인에서 시작하며 이 시간은 절대 시간이어야 합니다. 이후 이벤트에는 첫 번째 시간소인에 대해 상대적으로 이전(과거) 또는 이후(미래)인 시간소인이 포함될 수 있습니다. 그러나 이벤트를 처리하는 순서는 이벤트 순서에 따른 순서입니다. 다시 말해, 모든 이벤트는 발생 시간과 관계 없이 처리됩니다.

또는 상대적 시간소인으로 이벤트 순서를 작성하려는 경우, 생성하는 첫 번째 이벤트 다음에 time-stamped by the test scenario 생성을 사용할 수 있습니다. 첫 번째 이벤트에서 이 생성을 사용하는 경우, 후속 이벤트 모두는 순서에서 이들 바로 앞에 오는 이벤트와 비교하여 시간소인이 지정됩니다. 그런 다음 여러 시간소인에 같은 순서를 생성하여 테스트 시나리오의 이벤트 순서를 다시 사용할 수 있습니다.

프로시저

  1. 이벤트 순서 파일을 작성하십시오.
    1. 솔루션 맵에서 이벤트 순서 작성을 클릭하십시오.
    2. 이벤트 순서 마법사의 작업공간에서 테스트 클라이언트 프로젝트를 선택하고 이벤트 순서 파일의 이름을 입력하십시오.
    3. 완료를 클릭하십시오.
    이벤트 순서 파일은 솔루션의 이벤트 순서 폴더에 저장됩니다. 새 .eseq 파일이 열립니다.
  2. .eseq 파일의 텍스트 편집기를 여십시오.
  3. 스페이스 또는 Ctrl+스페이스를 눌러서 사용 가능한 구성을 보십시오.
  4. 구성을 두 번 클릭하여 이를 정의에 삽입하십시오.

    예를 들어, the customer를 John으로 식별하는 변수를 정의하려면 다음 행을 작성하십시오. define 'the customer' as the customer identified by "John";. 그러면 이 변수를 사용하여 emit 구성에서 the customer를 참조할 수 있습니다.

  5. 옵션: 오브젝트를 이벤트와 연관된 오브젝트 콜렉션에 추가하십시오.

    예를 들어, purchase 이벤트 유형에는 price 및 amount 속성이 포함된 항목의 목록이 있습니다. 다음 행은 purchase1을 엔티티 the customer와 관련된 새 이벤트로 정의합니다. add 구성에서는 purchase1 이벤트의 price 및 amount에 대한 특정 값이 있는 새 오브젝트를 추가합니다.

    define 'purchase1' as a new purchase where 
       the customer is 'the customer'; add ( a new item where
       the price is 10 ,
       the amount is 1 )
       to the items of purchase1 ;
  6. 옵션: 순서에 포함시킬 각 이벤트에 대해 emit 생성을 추가하십시오. 이 이벤트는 변수 이름이나 특정 유형의 새 이벤트를 나타낼 수 있습니다. 이벤트에는 발생한 시기를 표시하는 시간소인이 필요하며, 첫 번째 이벤트에서는 절대 시간소인이 필요합니다. 순서에 있는 첫 번째 이벤트의 경우, 이벤트 순서에 또는 테스트 시나리오에 절대 시간소인을 포함하도록 선택할 수 있습니다.
    • 이벤트 순서에 시간소인을 추가하려면, 첫 번째 이벤트에 time-stamped <date & time> 절을 첨부하십시오. 이후 이벤트에는 순서에 필요한 만큼의 절대 또는 상대 시간소인이 포함될 수 있습니다.

      다음 예제에서 생성된 첫 번째 이벤트(purchase1)에는 절대 시간소인이 있고, 생성된 두 번째 및 세 번째 이벤트(purchase2 및 purchase3 순서)에는 상대적 시간소인이 있습니다. 이벤트는 2:00:00 PM, 2:05:00 PM, 2:15:00 PM에 생성됩니다.

      emit purchase1, time-stamped 3/20/2016 2:00:00 PM ;
      emit purchase2 , time-stamped 5 minutes later ;
      emit purchase3 , time-stamped 10 minutes later ;

      이벤트에 시간소인 속성이 있고 time-stamped 생성을 사용하는 경우, 시간소인 속성이 대체되고 경고가 발생합니다. 다음 예제에서 처리되는 유일한 시간소인은 시간소인 1 hour later이며 이 시간소인은 시퀀스의 이전 이벤트 시간소인에 대해 상대적입니다.

      emit a new request event where
         the timestamp is 1/1/2015 ,
         time-stamped 1 hour later ;
    • 상대 시간소인만 있는 순서를 작성하려면 첫 번째 이벤트에 time-stamped by the test scenario 절을 첨부하십시오. 이 절을 추가하면, 이벤트를 제출할 때마다 테스트 시나리오에서 시간소인을 지정할 수 있으므로, 이벤트 순서를 다시 사용하기가 쉬워집니다. 각 이벤트가 바로 앞에 처리된 이벤트와 관련하여 생성되도록 이후 각 이벤트에 상대 시간소인이 있는지 확인하십시오.
      다음 예제에서 새 구매 이벤트에서는 테스트 시나리오의 시간소인을 사용합니다. 첫 번째 이벤트 이후, 다음 이벤트 모두에는 상대 시간소인이 있습니다.
      emit a new purchase, time-stamped by the test scenario ;
      emit a new purchase ,
         2 hours later ;
      emit a new purchase , 
         30 minutes later ;
      테스트 시나리오에서 이 예제 이벤트 순서를 제출하고 time-stamped 1/1/2016 10:00:00 AM이 되도록 지정하면, 두 개의 다른 새 구매 이벤트가 1/1/2016 12:00:00 및 1/1/2016 12:30:00에 각각 제출됩니다.
  7. 시퀀스의 모든 이벤트에 해당 emit 구성을 확인하십시오.
  8. 파일을 저장하십시오.

예

이벤트 속성

이벤트에는 시간소인이 있는 이벤트 속성이 포함될 수 있습니다. 다음 예에서는 request event 속성에 시간소인이 있습니다.

emit a new response event where
   the in response to is ( a new request event where the timestamp is 1/1/2015 ) ,
   time-stamped 1/2/2015 ;

다음 예제에서 new customer registration 이벤트의 address 속성은 emit 구성 안에 작성됩니다. where 구성은 a new <item> 구성 안에서 사용됩니다.

emit a new customer registration where
   the address is ( a new address where
      the street is "221B Baker Street" ,
      the city is "London" ,
      the country is "UK" ) ,
      time-stamped 3/25/2015 ;
상대 시간소인이 있는 이벤트 순서
다음 예제에서 구매 이벤트는 테스트 시나리오에서 지정한 시간에 고객 Fred가 생성합니다. 두 번째 및 세 번째 구매는 첫 번째 구매 이벤트 이후 3일 및 5일 후에 생성됩니다.
emit a new purchase where
the customer is the customer
   "Fred",
   the amount is 100.0, 
   time-stamped by the test scenario ;

emit a new purchase where
   the customer is the customer
   "Fred",  the amount is 50,
   time-stamped 3 days later ;

emit a new purchase where
   the customer is the customer 
   "Fred",
   the amount is 250, 
   time-stamped 2 days later ;
별도의 개념 정의가 있는 이벤트 순서
다음 예에서는 이벤트 순서가 customer registration 이벤트 및 purchase 이벤트의 두 개 이벤트로 구성되며 이들 이벤트는 두 개의 변수인 the customer 및 purchase1에 연관되어 있습니다. 이러한 변수는 emit 문 외부의 define 문에 정의되어 있습니다. 괄호는 선택적입니다.
define 'the customer' as the customer identified by "John";

emit ( a new customer registration where
   the customer is 'the customer' ,
   the first name is "John" ,
   the last name is "Watson" ) ,
   time-stamped 3/25/2015 ;

define 'purchase1' as a new purchase where 
   the customer is 'the customer'; 
emit purchase1 ,
   time-stamped 5 minutes later;
인라인 개념 정의가 있는 이벤트 순서
다음 예에서는 이벤트 순서가 customer registration 이벤트 및 purchase 이벤트의 두 개 이벤트로 구성되며 이들 이벤트는 두 개의 변수인 the customer 및 purchase1에 연관되어 있습니다. the customer의 주소 속성에 대한 변수는 customer registration 이벤트의 emit 정의 내부에 정의됩니다. 주소 인스턴스는 관계를 설정하는 데 사용하므로 new customer registration 이벤트는 ID가 아닌 주소 개념 유형에 대한 속성 값을 포함하지 않습니다. 괄호는 선택적입니다.
define 'the customer' as the customer identified by "John";

emit a new customer registration where
   the customer is 'the customer' ,
   the first name is "John" ,
   the last name is "Watson" ,
   the address is ( a new address where
      the address id is "123"
      the street is "221B Baker Street" ,
      the city is "London" ,
      the country is "UK" ) ,
   time-stamped 3/25/2015 ;

define 'purchase1' as a new purchase where 
   the customer is 'the customer'; 
emit purchase1 ,
   time-stamped 5 minutes later;
두 개의 이벤트에서 같은 변수를 사용하는 이벤트 순서
다음 예에서 변수 paddington은 특정 customer를 참조하기 위해 각 이벤트에서 재사용합니다.
define 'paddington' as the customer identified by "paddington@example.com"

emit a new customer registration where
   the customer is paddington ,
   time-stamped 4/07/2015 ;

emit a new purchase where
   the customer is paddington ,
   the price is 25 ,
   time-stamped 10 minutes later ;

emit a new purchase where
   the customer is paddington ,
   the price is 62 ,
   time-stamped 3 days later ;
다른 유형의 시간소인을 사용하는 이벤트가 있는 이벤트 순서
다음 예에서 첫 번째 purchase 이벤트에는 customer registration 이벤트보다 10분 후인 시간소인이 있습니다. 시퀀스의 세 번째 이벤트는 이전 이벤트의 3일 후에 발생하며 이 예에서는 customer registration 이벤트입니다. 이러한 이벤트에서는 순서에 따라 처리되지 않은 이벤트 순서를 시뮬레이션하는 방법을 예로 보여줍니다.
define 'paddington' as the customer identified by "paddington@example.com"

emit a new purchase where
   the customer is paddington ,
   the price is 25 ,
   time-stamped 4/07/2015 ;

emit a new customer registration where
   the customer is paddington ,
   time-stamped 10 minutes earlier ;

emit a new purchase where
   the customer is paddington ,
   the price is 62 ,
   time-stamped 3 days later ;

다음에 수행할 작업

이벤트 순서를 정의하면 해당 순서를 실행하여 솔루션에 대해 테스트할 수 있습니다.