当前位置: 首页>>代码示例>>Java>>正文


Java States类代码示例

本文整理汇总了Java中org.jmock.States的典型用法代码示例。如果您正苦于以下问题:Java States类的具体用法?Java States怎么用?Java States使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


States类属于org.jmock包,在下文中一共展示了States类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldAddMyselfAsLeaderOfMetaToRoot

import org.jmock.States; //导入依赖的package包/类
@Test
public void shouldAddMyselfAsLeaderOfMetaToRoot() throws Throwable {
  final States state = context.states("request-message").startsAs("not-run");

  context.checking(new Expectations() {{
    oneOf(moduleInformationProvider).getModule(ModuleType.ControlRpc);
    will(returnFutureWithValue(controlRpcModule));

    oneOf(moduleInformationProvider).getModule(ModuleType.Tablet);
    will(returnFutureWithValue(tabletModule));

    oneOf(tabletModule).getTablet(with(any(String.class)), with(any(ByteBuffer.class)));
    will(returnValue(rootTablet));

    oneOf(rootTablet).getLeader();
    will(returnValue(NODE_ID));

    oneOf(controlRpcModule).doMessage(with(any(Request.class)));
    then(state.is("done"));
  }});

  MetaTabletLeaderBehavior metaTabletLeaderBehavior =
      new MetaTabletLeaderBehavior(NODE_ID, moduleInformationProvider);
  metaTabletLeaderBehavior.start();
  sync.waitUntil(state.is("done"));
}
 
开发者ID:cloud-software-foundation,项目名称:c5,代码行数:27,代码来源:MetaTabletLeaderBehaviorTest.java

示例2: queryWithMoreThanOneProperty

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryWithMoreThanOneProperty() throws Exception{
	queryMockClass.addProperty("name", String.class);
	queryMockClass.addProperty("lastName", String.class);
	queryMockClass.addProperty("age", int.class);
	queryMockClass.addProperty("addressCity", String.class);
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPerson", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("lastName", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("age", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("address.city", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	 	one(visitorMock).visitEnd(); when(s.is("conector"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:25,代码来源:QueryObjectMethodParserTest.java

示例3: queryWithPropertiesAndMethods

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryWithPropertiesAndMethods() throws Exception{
	queryMockClass.addMethod(String.class, "getName");
	queryMockClass.addMethod(String.class, "getLastName");
	queryMockClass.addProperty("age", int.class);
	queryMockClass.addProperty("addressCity", String.class);
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPerson", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("lastName", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("age", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("address.city", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	 	one(visitorMock).visitEnd(); when(s.is("conector"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:25,代码来源:QueryObjectMethodParserTest.java

示例4: queryWithComparisonTypesOnProperties

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryWithComparisonTypesOnProperties() throws Exception{
	queryMockClass.addProperty("nameContains", String.class);
	queryMockClass.addProperty("ageGreater", int.class);
	queryMockClass.addProperty("addressCityStarts", String.class);
	queryMockClass.addProperty("addressNumberLesserOrEquals", int.class);
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPerson", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.CONTAINS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("age", ComparisonType.GREATER);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("address.city", ComparisonType.STARTS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("address.number", ComparisonType.LESSER_OR_EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	 	one(visitorMock).visitEnd(); when(s.is("conector"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:25,代码来源:QueryObjectMethodParserTest.java

示例5: queryWithComparisonTypesOnMethods

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryWithComparisonTypesOnMethods() throws Exception{
	queryMockClass.addMethod(String.class, "getNameContains");
	queryMockClass.addMethod(int.class, "getAgeGreater");
	queryMockClass.addMethod(String.class, "getAddressCityStarts");
	queryMockClass.addMethod(int.class, "getAddressNumberLesserOrEquals");
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPerson", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.CONTAINS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("age", ComparisonType.GREATER);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("address.city", ComparisonType.STARTS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("address.number", ComparisonType.LESSER_OR_EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	 	one(visitorMock).visitEnd(); when(s.is("conector"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:25,代码来源:QueryObjectMethodParserTest.java

示例6: queryWithComparisonTypesUsingAnnotations

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryWithComparisonTypesUsingAnnotations() throws Exception{
	queryMockClass.addProperty("name", String.class);
	queryMockClass.addAnnotation("name", Contains.class, Location.FIELD);
	queryMockClass.addProperty("addressNumber", int.class);
	queryMockClass.addAnnotation("addressNumber", Greater.class, Location.GETTER);
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPerson", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.CONTAINS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("address.number", ComparisonType.GREATER);when(s.is("condicao"));then(s.is("conector"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	 	one(visitorMock).visitEnd(); when(s.is("conector"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:23,代码来源:QueryObjectMethodParserTest.java

示例7: queryWithComparisonTypesUsingAnnotationsOnMethods

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryWithComparisonTypesUsingAnnotationsOnMethods() throws Exception{
	queryMockClass.addMethod(String.class, "getName");
	queryMockClass.addMethodAnnotation("getName", Contains.class);
	queryMockClass.addMethod(int.class, "getAddressNumber");
	queryMockClass.addMethodAnnotation("getAddressNumber", Greater.class);
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPerson", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.CONTAINS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("address.number", ComparisonType.GREATER);when(s.is("condicao"));then(s.is("conector"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	 	one(visitorMock).visitEnd(); when(s.is("conector"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:23,代码来源:QueryObjectMethodParserTest.java

示例8: queryWithNullOptions

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryWithNullOptions() throws Exception{
	queryMockClass.addProperty("name", String.class);
	queryMockClass.addAnnotation("name", IgnoreWhenNull.class, Location.FIELD);
	queryMockClass.addProperty("lastNameStarts", String.class);
	queryMockClass.addAnnotation("lastNameStarts", CompareToNull.class, Location.GETTER);
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPerson", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.EQUALS, NullOption.IGNORE_WHEN_NULL);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("lastName", ComparisonType.STARTS, NullOption.COMPARE_TO_NULL);when(s.is("condicao"));then(s.is("conector"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	 	one(visitorMock).visitEnd(); when(s.is("conector"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:23,代码来源:QueryObjectMethodParserTest.java

示例9: queryWithOrderBy

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryWithOrderBy() throws Exception{
	queryMockClass.addProperty("name", String.class);
	queryMockClass.addProperty("age", int.class);
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPersonOrderByLastNameDesc", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("age", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitOrderBy("lastName", OrderingDirection.DESC);when(s.is("conector"));then(s.is("final"));
   	 	one(visitorMock).visitEnd(); when(s.is("final"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:22,代码来源:QueryObjectMethodParserTest.java

示例10: queryMethodsWithOrderBy

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryMethodsWithOrderBy() throws Exception{
	queryMockClass.addMethod(String.class, "getName");
	queryMockClass.addMethod(int.class, "age");
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPersonOrderByLastNameDesc", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("age", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitOrderBy("lastName", OrderingDirection.DESC);when(s.is("conector"));then(s.is("final"));
   	 	one(visitorMock).visitEnd(); when(s.is("final"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:22,代码来源:QueryObjectMethodParserTest.java

示例11: queryWithDomainTerm

import org.jmock.States; //导入依赖的package包/类
@Test
public void queryWithDomainTerm() throws Exception{
	Annotation an = domainTermWithOneCondition("underage","age", "18", ComparisonType.LESSER);
	mockClass.addAnnotation(an);
	queryMockClass.addProperty("name", String.class);
	queryMockClass.addProperty("lastNameStarts", String.class);
	queryClass = queryMockClass.createClass();
	Method m = createMethodWithAnnotationForTesting(Person.class, "getPersonUnderage", QueryObject.class, queryClass);
	QueryInfo qi = parser.parse(m); 
	final QueryVisitor visitorMock = context.mock(QueryVisitor.class);
    
    context.checking(new Expectations() {{
    	States s = context.states("QUERY").startsAs("inicio");
   	 	one(visitorMock).visitEntity("Person");when(s.is("inicio"));then(s.is("condicao"));
   	 	one(visitorMock).visitCondition("name", ComparisonType.EQUALS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("lastName", ComparisonType.STARTS);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitCondition("age", ComparisonType.LESSER, 18);when(s.is("condicao"));then(s.is("conector"));
   	 	one(visitorMock).visitEnd(); when(s.is("conector"));
   	 	allowing(visitorMock).visitConector("and");when(s.is("conector"));then(s.is("condicao"));
   	}});
    
    qi.visit(visitorMock);	
}
 
开发者ID:EsfingeFramework,项目名称:querybuilder,代码行数:24,代码来源:QueryObjectMethodParserTest.java

示例12: testErrorMessagesIncludeCurrentStates

import org.jmock.States; //导入依赖的package包/类
public void testErrorMessagesIncludeCurrentStates() {
    readiness.startsAs("ethelred");
    
    States fruitiness = context.states("fruitiness");
    fruitiness.startsAs("apple");
    
    context.checking(new Expectations() {{
        allowing (mock).method1(); when(readiness.is("ready"));
    }});
    
    try {
        mock.method1();
        fail("should have thrown ExpectationError");
    }
    catch (ExpectationError e) {
        String message = e.toString();
        
        AssertThat.stringIncludes("should describe readiness state", 
                                  "readiness is ethelred", message);
        AssertThat.stringIncludes("should describe fruitiness state", 
                                  "fruitiness is apple", message);
    }
}
 
开发者ID:Shared-Business-Service,项目名称:jMock-Demo,代码行数:24,代码来源:StatesAcceptanceTest.java

示例13: canWaitForAStateMachineToEnterAGivenState

import org.jmock.States; //导入依赖的package包/类
@Test(timeout=250)
public void canWaitForAStateMachineToEnterAGivenState() throws InterruptedException {
    final AtomicInteger counter = new AtomicInteger(blitzer.totalActionCount());
    
    final States threads = mockery.states("threads");
    
    mockery.checking(new Expectations() {{
        exactly(blitzer.totalActionCount()).of(mockObject).action();
            when(threads.isNot("finished"));
            
        oneOf(mockObject).finished();
            then(threads.is("finished"));
    }});
    
    blitzer.blitz(new Runnable() {
        public void run() {
            mockObject.action();
            if (counter.decrementAndGet() == 0) {
                mockObject.finished();
            }
        }
    });
    
    synchroniser.waitUntil(threads.is("finished"));
}
 
开发者ID:Shared-Business-Service,项目名称:jMock-Demo,代码行数:26,代码来源:SynchroniserTests.java

示例14: canWaitForAStateMachineToEnterAGivenStateWithinSomeTimeout

import org.jmock.States; //导入依赖的package包/类
@Test(timeout=250)
public void canWaitForAStateMachineToEnterAGivenStateWithinSomeTimeout() throws InterruptedException {
    final States threads = mockery.states("threads");
    
    mockery.checking(new Expectations() {{
        exactly(blitzer.totalActionCount()).of(mockObject).action();
            when(threads.isNot("finished"));
            
        oneOf(mockObject).finished();
            then(threads.is("finished"));
    }});
    
    blitzer.blitz(new Runnable() {
        AtomicInteger counter = new AtomicInteger(blitzer.totalActionCount());
        
        public void run() {
            mockObject.action();
            if (counter.decrementAndGet() == 0) {
                mockObject.finished();
            }
        }
    });
    
    synchroniser.waitUntil(threads.is("finished"), 100);
}
 
开发者ID:Shared-Business-Service,项目名称:jMock-Demo,代码行数:26,代码来源:SynchroniserTests.java

示例15: throwsExpectationErrorIfExpectationFailsWhileWaitingForStateMachine

import org.jmock.States; //导入依赖的package包/类
@Test
public void throwsExpectationErrorIfExpectationFailsWhileWaitingForStateMachine() throws InterruptedException {
    final States threads = mockery.states("threads");
    
    // This will cause an expectation error, and nothing will make
    // the "threads" state machine transition to "finished" 
    
    blitzer.blitz(new Runnable() {
        public void run() {
            mockObject.action();
        }
    });
    
    try {
        synchroniser.waitUntil(threads.is("finished"), 100);
        fail("should have thrown AssertionError");
    }
    catch (AssertionError e) {
        assertThat(e.getMessage(), containsString("action()"));
    }
}
 
开发者ID:Shared-Business-Service,项目名称:jMock-Demo,代码行数:22,代码来源:SynchroniserTests.java


注:本文中的org.jmock.States类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。