<commit_before>/*
 * test_HandleToken.cpp
 *
 *  Created on: 30 sep. 2015
 *      Author: <NAME>
 */
#ifdef _MOCK_

#include "gtest/gtest.h"
#include "../src/Token.h"

class test_HandleToken : public ::testing::Test {
protected:
	virtual void SetUp() {}
	virtual void TearDown() {}
};

// A test method for testing the handleToken function
TEST(test_HandleToken, handleToken) {
	// Create an instance of the Token
	Token token;

	// Create two empty JsonObject with an StaticJsonBuffer
	StaticJsonBuffer<400> jsonBuffer;
	JsonObject &reply = jsonBuffer.createObject();
	JsonObject &msg = jsonBuffer.createObject();

	// Add String values for testing, remove in the final project.
	msg["sequencenbr"] = "1234";
	msg["port_id"] = "4321";
	msg["peer_port_id"] = "5678";

	// Initiate the handleToken function so that JsonObject reply
	// is filled. If object is valid it will return 1, otherwise 2
	EXPECT_EQ(1, token.handleToken(msg, reply));

	// Checks if reply contains the key that we want
	EXPECT_TRUE(reply.containsKey("cmd"));
	EXPECT_TRUE(reply.containsKey("sequencenbr"));
	EXPECT_TRUE(reply.containsKey("port_id"));
	EXPECT_TRUE(reply.containsKey("peer_port_id"));
	EXPECT_TRUE(reply.containsKey("value"));

	//
	EXPECT_EQ(5, reply.size());

	EXPECT_STREQ("TOKEN_REPLY", reply.get("cmd"));
	EXPECT_STREQ(msg.get("sequencenbr"), reply.get("sequencenbr"));
	EXPECT_STREQ("4321", reply.get("port_id"));
	EXPECT_STREQ("5678", reply.get("peer_port_id"));
	EXPECT_STREQ("ACK", reply.get("value"));
}

#endif<commit_msg>Updated the handleToken function<commit_after>/*
 * test_HandleToken.cpp
 *
 *  Created on: 30 sep. 2015
 *      Author: <NAME>
 */
#ifdef _MOCK_

#include "gtest/gtest.h"
#include "../src/Token.h"

class test_HandleToken : public ::testing::Test {
protected:
	virtual void SetUp() {}
	virtual void TearDown() {}
};

// A test method for testing the handleToken function
TEST(test_HandleToken, handleToken) {
	// Create an instance of the Token
	Token token;

	// Create two empty JsonObject with an StaticJsonBuffer
	StaticJsonBuffer<400> jsonBuffer;
	JsonObject &reply = jsonBuffer.createObject();
	JsonObject &msg = jsonBuffer.createObject();

	// Add String values for testing, remove in the final project.
	msg["sequencenbr"] = "1234";
	msg["port_id"] = "4321";
	msg["peer_port_id"] = "5678";

	// Initiate the handleToken function so that JsonObject reply
	// is filled. If object is valid it will return 1, otherwise 2
	EXPECT_EQ(1, token.handleToken(msg, reply));

	// Checks if reply contains the key that we want
	EXPECT_TRUE(reply.containsKey("cmd"));
	EXPECT_TRUE(reply.containsKey("sequencenbr"));
	EXPECT_TRUE(reply.containsKey("port_id"));
	EXPECT_TRUE(reply.containsKey("peer_port_id"));
	EXPECT_TRUE(reply.containsKey("value"));

	// Checks if the JsonObject is the correct size
	EXPECT_EQ(5, reply.size());

	// Checks if the reply value is correct
	EXPECT_STREQ("TOKEN_REPLY", reply.get("cmd"));
	EXPECT_STREQ(msg.get("sequencenbr"), reply.get("sequencenbr"));
	EXPECT_STREQ("4321", reply.get("port_id"));
	EXPECT_STREQ("5678", reply.get("peer_port_id"));
	EXPECT_STREQ("ACK", reply.get("value"));
}

#endif
{'fraction_non_alphanumeric': 0.14489990467111535, 'fraction_numerical': 0.020972354623450904, 'mean_word_length': 5.209072978303747, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2330901', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1055, 'n_words': 267}