NEMOparser implements NEMOparserConstants { static final public String NodeModel(UserId userId, DataBroker dataBroker, TenantManage tenantManage) throws ParseException { String strReturn = null; Token nodeModelName = null; Token parameterType = null; Token parameterName = null; Token parameterType1 = null; Token parameterName1 = null; LinkedHashMap<String, String> parameters = new LinkedHashMap< String, String >(); UpdateTemplateDefinitionLang definition = new UpdateTemplateDefinitionLang(dataBroker, tenantManage); nodeModelName = jj_consume_token(ID); jj_consume_token(PROPERTY); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING: parameterType = jj_consume_token(STRING); break; case INTEGER: parameterType = jj_consume_token(INTEGER); break; case RANGE: parameterType = jj_consume_token(RANGE); break; default: jj_la1[27] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jj_consume_token(COLON); parameterName = jj_consume_token(ID); parameters.put(parameterName.image, parameterType.image); label_9: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[28] = jj_gen; break label_9; } jj_consume_token(COMMA); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING: parameterType1 = jj_consume_token(STRING); break; case INTEGER: parameterType1 = jj_consume_token(INTEGER); break; case RANGE: parameterType1 = jj_consume_token(RANGE); break; default: jj_la1[29] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jj_consume_token(COLON); parameterName1 = jj_consume_token(ID); parameters.put(parameterName1.image, parameterType1.image); } jj_consume_token(SEMICOLON); label_10: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NODE: case CONNECTION: case FLOW: case OPERATION: ; break; default: jj_la1[30] = jj_gen; break label_10; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NODE: jj_consume_token(NODE); strReturn = abstractNode(definition); break; case CONNECTION: jj_consume_token(CONNECTION); strReturn = abstractConnection(definition); break; case FLOW: jj_consume_token(FLOW); strReturn = abstractFlow(definition); break; case OPERATION: jj_consume_token(OPERATION); strReturn = abstractOperation(definition); break; default: jj_la1[31] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } if(strReturn !=null) { {if (true) return strReturn;} } else { {if (true) return definition.templateDefinitionLang(userId, nodeModelName.image, parameters);} } throw new Error("Missing return statement in function"); } NEMOparser(java.io.InputStream stream);  NEMOparser(java.io.InputStream stream, String encoding);  NEMOparser(java.io.Reader stream);  NEMOparser(NEMOparserTokenManager tm); String parseNEMO(UserId userId,String strNEMO, DataBroker dataBroker, TenantManage tenantManage); static final String NEMO(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String UpdateIntent(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String DeleteIntent(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String UpdateNode(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String UpdateConnection(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String UpdateFlow(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String UpdateOperation(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String NodeModel(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String abstractNode(UpdateTemplateDefinitionLang definition); static final String abstractConnection(UpdateTemplateDefinitionLang definition); static final String abstractFlow(UpdateTemplateDefinitionLang definition); static final String abstractOperation(UpdateTemplateDefinitionLang definition); static final String DeleteNode(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String DeleteConnection(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String DeleteFlow(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String DeleteOperation(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final String Query(UserId userId, DataBroker dataBroker, TenantManage tenantManage); static final LinkedHashMap<String,String> conditionTarget(); static final LinkedHashMap<String,String> property(); static final LinkedHashMap<String,String> nodeMultiProperty(); static void ReInit(java.io.InputStream stream); static void ReInit(java.io.InputStream stream, String encoding); static void ReInit(java.io.Reader stream); void ReInit(NEMOparserTokenManager tm); static final Token getNextToken(); static final Token getToken(int index); static ParseException generateParseException(); static final void enable_tracing(); static final void disable_tracing(); static public NEMOparserTokenManager token_source; static public Token token; static public Token jj_nt; }
@Test public void testNodeModel() throws Exception { UserId userId = mock(UserId.class); DataBroker dataBroker = mock(DataBroker.class); TenantManage tenantManage = mock(TenantManage.class); Field field_jj_ntk = class1.getDeclaredField("jj_ntk"); field_jj_ntk.setAccessible(true); Field field_token = class1.getDeclaredField("token"); field_token.setAccessible(true); Token token = new Token(); Token token_ID = new Token(); token_ID.kind = NEMOparserConstants.ID; token_ID.image = "test"; Token token_PROPERTY = new Token(); token_PROPERTY.kind = NEMOparserConstants.PROPERTY; Token token_STRING = new Token(); token_STRING.kind = NEMOparserConstants.STRING; token_STRING.image = "test_string"; Token token_COLON = new Token(); token_COLON.kind = NEMOparserConstants.COLON; Token token_ID1 = new Token(); token_ID1.kind = NEMOparserConstants.ID; token_ID1.image = "test1"; Token token_SEMICOLON = new Token(); token_SEMICOLON.kind = NEMOparserConstants.SEMICOLON; Token token_NODE = new Token(); token_NODE.kind = NEMOparserConstants.NODE; token.next = token_ID; token_ID.next = token_PROPERTY; token_PROPERTY.next = token_STRING; token_STRING.next = token_COLON; token_COLON.next = token_ID1; token_ID1.next = token_SEMICOLON; token_SEMICOLON.next = token_NODE; field_jj_ntk.set(class1, NEMOparserConstants.STRING); field_token.set(class1, token); PowerMockito.spy(NEMOparser.class); PowerMockito.when(NEMOparser.class,"jj_ntk") .thenReturn(NEMOparserConstants.NODE) .thenReturn(NEMOparserConstants.NODE) .thenReturn(NEMOparserConstants.SEMICOLON); PowerMockito.mockStatic(NEMOparser.class); PowerMockito.when(NEMOparser.abstractNode(any(UpdateTemplateDefinitionLang.class))).thenReturn("zhangmeng"); Assert.assertTrue(NEMOparser.NodeModel(userId, dataBroker, tenantManage) == null); }