@Test
public void sameObjectBeforeAndAfterSerializing() throws Exception {

	System.out.println(CLASS_NAME + ":sameObjectBeforeAndAfterSerializing");
	//FOR USER
	User user = new User(8, null, textMismatch, null, textMismatch, null, true, true);
	user.setUuid(UUID.randomUUID());
	List<PerunBean> userInList = AuditParser.parseLog(user.serializeToString());
	assertEquals(user.toString(), ((User) userInList.get(0)).toString());
	assertEquals(user.getFirstName(), ((User) userInList.get(0)).getFirstName());
	assertEquals(user.getUuid(), ((User) userInList.get(0)).getUuid());
	//FOR EXTSOURCE
	ExtSource extSource = new ExtSource(11, null, textMismatch);
	List<PerunBean> extSourceInList = AuditParser.parseLog(extSource.serializeToString());
	assertEquals(extSource.toString(), ((ExtSource) extSourceInList.get(0)).toString());
	assertEquals(extSource.getName(), ((ExtSource) extSourceInList.get(0)).getName());
	//FOR USEREXTSOURCE
	UserExtSource userExtSource1 = new UserExtSource(15, extSource, null , 8, 15);
	UserExtSource userExtSource2 = new UserExtSource(15, null, textMismatch, 8, 15);
	List<PerunBean> userExtSource1InList = AuditParser.parseLog(userExtSource1.serializeToString());
	List<PerunBean> userExtSource2InList = AuditParser.parseLog(userExtSource2.serializeToString());
	assertEquals(userExtSource1.toString(), ((UserExtSource) userExtSource1InList.get(0)).toString());
	assertEquals(userExtSource2.toString(), ((UserExtSource) userExtSource2InList.get(0)).toString());
	assertEquals(userExtSource1.getLogin(), ((UserExtSource) userExtSource1InList.get(0)).getLogin());
	assertEquals(userExtSource2.getExtSource(), ((UserExtSource) userExtSource2InList.get(0)).getExtSource());
	//FOR VO (VO MUST HAVE ALL ATTRIBUTE NOT NULL)
	Vo vo = new Vo(18, textMismatch, textMismatch);
	List<PerunBean> voInList = AuditParser.parseLog(vo.serializeToString());
	assertEquals(vo.toString(), ((Vo) voInList.get(0)).toString());
	assertEquals(vo.getName(), ((Vo) voInList.get(0)).getName());
	//FOR FACILITY
	Facility facility = new Facility(15, null);
	List<PerunBean> facilityInList = AuditParser.parseLog(facility.serializeToString());
	assertEquals(facility.toString(), ((Facility) facilityInList.get(0)).toString());
	assertEquals(facility.getName(), ((Facility) facility).getName());
	//FOR RESOURCE
	Resource resource = new Resource(15, textMismatch, null, 10, 10);
	resource.setUuid(UUID.randomUUID());
	List<PerunBean> resourceInList = AuditParser.parseLog(resource.serializeToString());
	assertEquals(resource.toString(), ((Resource) resourceInList.get(0)).toString());
	assertEquals(resource.getDescription(), ((Resource) resourceInList.get(0)).getDescription());
	assertEquals(resource.getUuid(), ((Resource) resourceInList.get(0)).getUuid());
	//FOR GROUP
	Group group = new Group(textMismatch, null);
	group.setId(15);
	group.setUuid(UUID.randomUUID());
	group.setParentGroupId(320);
	Group group2 = new Group(textMismatch, null);
	group2.setId(36);
	group2.setParentGroupId(null);
	List<PerunBean> groupInList = AuditParser.parseLog(group.serializeToString());
	List<PerunBean> groupInList2 = AuditParser.parseLog(group2.serializeToString());
	assertEquals(group.toString(), ((Group) groupInList.get(0)).toString());
	assertEquals(group.getDescription(), ((Group) groupInList.get(0)).getDescription());
	assertEquals(group.getUuid(), ((Group) groupInList.get(0)).getUuid());
	assertEquals(group2.toString(), ((Group) groupInList2.get(0)).toString());
	assertEquals(group2.getParentGroupId(), ((Group) groupInList2.get(0)).getParentGroupId());
	//FOR RESOURCE TAG
	List<PerunBean> resourceTagInList1 = AuditParser.parseLog(resourceTag1.serializeToString());
	List<PerunBean> resourceTagInList2 = AuditParser.parseLog(resourceTag2.serializeToString());
	assertEquals(resourceTag1.toString(), ((ResourceTag) resourceTagInList1.get(0)).toString());
	assertEquals(resourceTag1.getTagName(), ((ResourceTag) resourceTagInList1.get(0)).getTagName());
	assertEquals(resourceTag2.toString(), ((ResourceTag) resourceTagInList2.get(0)).toString());
	assertEquals(resourceTag2.getTagName(), ((ResourceTag) resourceTagInList2.get(0)).getTagName());
	//FOR MEMBER
	Member member = new Member(6, 8, 8, null);
	member.setSourceGroupId(null);
	List<PerunBean> memberInList = AuditParser.parseLog(member.serializeToString());
	assertEquals(member.toString(), ((Member) memberInList.get(0)).toString());
	assertEquals(member.getStatus(), ((Member) memberInList.get(0)).getStatus());
	//FOR DESTINATION
	Destination destination = new Destination(7, null, textMismatch);
	List<PerunBean> destinationInList = AuditParser.parseLog(destination.serializeToString());
	assertEquals(destination.toString(), ((Destination) destinationInList.get(0)).toString());
	assertEquals(destination.getDestination(), ((Destination) destinationInList.get(0)).getDestination());
	//FOR HOST
	Host host = new Host(5, null);
	List<PerunBean> hostInList = AuditParser.parseLog(host.serializeToString());
	assertEquals(host.toString(), ((Host) hostInList.get(0)).toString());
	assertEquals(host.getHostname(), ((Host) hostInList.get(0)).getHostname());
	//FOR OWNER
	Owner owner = new Owner(5, null, textMismatch, OwnerType.administrative);
	List<PerunBean> ownerInList = AuditParser.parseLog(owner.serializeToString());
	assertEquals(owner.toString(), ((Owner) ownerInList.get(0)).toString());
	assertEquals(owner.getName(), ((Owner) ownerInList.get(0)).getName());
	//FOR SERVICE
	Service service = new Service(8, null, null);
	List<PerunBean> serviceInList = AuditParser.parseLog(service.serializeToString());
	assertEquals(service.toString(), ((Service) serviceInList.get(0)).toString());
	assertEquals(service.getName(), ((Service) serviceInList.get(0)).getName());
	assertEquals(service.getDescription(), ((Service) serviceInList.get(0)).getDescription());
	assertEquals(service.getDelay(), ((Service) serviceInList.get(0)).getDelay());
	assertEquals(service.getRecurrence(), ((Service) serviceInList.get(0)).getRecurrence());
	assertEquals(service.isEnabled(), ((Service) serviceInList.get(0)).isEnabled());
	assertEquals(service.getScript(), ((Service) serviceInList.get(0)).getScript());
	//FOR ATTRIBUTE DEFINITION
	AttributeDefinition attributeDefinition1 = new AttributeDefinition(getAttributeDefinition1());
	AttributeDefinition attributeDefinition2 = new AttributeDefinition(getAttributeDefinition2());
	AttributeDefinition attributeDefinition3 = new AttributeDefinition(getAttributeDefinition3());
	AttributeDefinition attributeDefinition4 = new AttributeDefinition(getAttributeDefinition4());
	attributeDefinition1.setType(null);
	attributeDefinition1.setDescription(null);
	attributeDefinition1.setFriendlyName(null);
	attributeDefinition1.setNamespace(null);
	List<PerunBean> attributeDefinition1InList = AuditParser.parseLog(attributeDefinition1.serializeToString());
	assertEquals(attributeDefinition1.toString(), ((AttributeDefinition) attributeDefinition1InList.get(0)).toString());
	assertEquals(attributeDefinition1.getNamespace(), ((AttributeDefinition) attributeDefinition1InList.get(0)).getNamespace());
	//FOR ATTRIBUTE
	Attribute attribute1 = new Attribute(getAttributeDefinition1());
	Attribute attribute2 = new Attribute(getAttributeDefinition2());
	Attribute attribute3 = new Attribute(getAttributeDefinition3());
	Attribute attribute4 = new Attribute(getAttributeDefinition4());
	Attribute attribute5 = new Attribute(getAttributeDefinition3());
	Attribute attribute6 = new Attribute(getAttributeDefinition4());
	attribute5.setValue(null);
	attribute6.setValue(null);
	attribute1.setValue(null);
	attribute2.setValue(null);
	attribute3.setValue(new ArrayList<String>(Arrays.asList(new String[] {"a", null, null})));
	Map<String, String> map = new LinkedHashMap<String, String>();
	map.put("a", null);
	map.put(null, "d");
	attribute4.setValue(map);
	List<PerunBean> attribute1InList = AuditParser.parseLog(attribute1.serializeToString());
	List<PerunBean> attribute2InList = AuditParser.parseLog(attribute2.serializeToString());
	List<PerunBean> attribute3InList = AuditParser.parseLog(attribute3.serializeToString());
	List<PerunBean> attribute4InList = AuditParser.parseLog(attribute4.serializeToString());
	List<PerunBean> attribute5InList = AuditParser.parseLog(attribute5.serializeToString());
	List<PerunBean> attribute6InList = AuditParser.parseLog(attribute6.serializeToString());
	assertEquals(attribute1.toString(), ((Attribute) attribute1InList.get(0)).toString());
	assertEquals(attribute2.toString(), ((Attribute) attribute2InList.get(0)).toString());
	assertEquals(attribute3.toString(), ((Attribute) attribute3InList.get(0)).toString());
	assertEquals(attribute4.toString(), ((Attribute) attribute4InList.get(0)).toString());
	assertEquals(attribute5.toString(), ((Attribute) attribute5InList.get(0)).toString());
	assertEquals(attribute6.toString(), ((Attribute) attribute6InList.get(0)).toString());
	assertEquals(attribute3.getValue(), ((Attribute) attribute3InList.get(0)).getValue());
	assertEquals(attribute4.getValue(), ((Attribute) attribute4InList.get(0)).getValue());
	assertEquals(attribute5.getValue(), ((Attribute) attribute5InList.get(0)).getValue());
	assertEquals(attribute6.getValue(), ((Attribute) attribute6InList.get(0)).getValue());
	//FOR CANDIDATE
	Map<String, String> attributesMap1 = new HashMap<String, String>();
	attributesMap1.put("test1", null);
	attributesMap1.put(null, null);
	Candidate candidate1 = new Candidate(userExtSource1, attributesMap1);
	Candidate candidate2 = new Candidate();
	candidate2.setUserExtSource(null);
	candidate2.setAttributes(null);
	candidate1.setId(5);
	candidate2.setId(6);
	candidate1.setAdditionalUserExtSources(null);
	List<UserExtSource> userExtSources = new ArrayList<UserExtSource>();
	userExtSources.add(userExtSource1);
	userExtSources.add(userExtSource2);
	candidate2.setAdditionalUserExtSources(userExtSources);
	List<PerunBean> candidate1InList = AuditParser.parseLog(candidate1.serializeToString());
	List<PerunBean> candidate2InList = AuditParser.parseLog(candidate2.serializeToString());
	assertEquals(candidate1.toString(), ((Candidate) candidate1InList.get(0)).toString());
	assertEquals(candidate2.toString(), ((Candidate) candidate2InList.get(0)).toString());
	assertEquals(candidate1.getAttributes(), ((Candidate) candidate1InList.get(0)).getAttributes());
	assertEquals(candidate2.getAttributes(), ((Candidate) candidate2InList.get(0)).getAttributes());
	//FOR SECURITY TEAM
	SecurityTeam securityTeam = new SecurityTeam(18, textMismatch, textMismatch);
	List<PerunBean> scsInList = AuditParser.parseLog(securityTeam.serializeToString());
	assertEquals(securityTeam.toString(), ((SecurityTeam) scsInList.get(0)).toString());
	assertEquals(securityTeam.getName(), ((SecurityTeam) scsInList.get(0)).getName());
	assertEquals(securityTeam.getDescription(), ((SecurityTeam) scsInList.get(0)).getDescription());
	//FOR TASK RESULT
	List<PerunBean> trList = AuditParser.parseLog(taskResult1.serializeToString());
	TaskResult taskResult2 = (TaskResult)trList.get(0);
	assertEquals(taskResult1.toString(), taskResult2.toString());
	//FOR BAN ON RESOURCE
	List<PerunBean> banOnResourceInList = AuditParser.parseLog(banOnResource1.serializeToString());
	assertEquals(banOnResource1.toString(), ((BanOnResource) banOnResourceInList.get(0)).toString());
	assertEquals(banOnResource1.getMemberId(), ((BanOnResource) banOnResourceInList.get(0)).getMemberId());
	assertEquals(banOnResource1.getResourceId(), ((BanOnResource) banOnResourceInList.get(0)).getResourceId());
	assertEquals(banOnResource1.getDescription(), ((BanOnResource) banOnResourceInList.get(0)).getDescription());
	assertEquals(banOnResource1.getValidityTo(), ((BanOnResource) banOnResourceInList.get(0)).getValidityTo());
	//FOR BAN ON FACILITY
	List<PerunBean> banOnFacilityInList = AuditParser.parseLog(banOnFacility1.serializeToString());
	assertEquals(banOnFacility1.toString(), ((BanOnFacility) banOnFacilityInList.get(0)).toString());
	assertEquals(banOnFacility1.getUserId(), ((BanOnFacility) banOnFacilityInList.get(0)).getUserId());
	assertEquals(banOnFacility1.getFacilityId(), ((BanOnFacility) banOnFacilityInList.get(0)).getFacilityId());
	assertEquals(banOnFacility1.getDescription(), ((BanOnFacility) banOnFacilityInList.get(0)).getDescription());
	assertEquals(banOnFacility1.getValidityTo(), ((BanOnFacility) banOnFacilityInList.get(0)).getValidityTo());
	//FOR RICHMEMBER
	RichMember richMember1 = new RichMember(null, member, null);
	//List<UserExtSource> userExtSources = new ArrayList<UserExtSource>();
	//userExtSources.add(userExtSource1);
	//userExtSources.add(null);
	//userExtSources.add(userExtSource2);
	//RichMember richMember2 = new RichMember(null, member, userExtSources);
	List<Attribute> listOfAttributes = new ArrayList<Attribute>();
	listOfAttributes.add(attribute1);
	listOfAttributes.add(attribute2);
	listOfAttributes.add(attribute3);
	listOfAttributes.add(attribute4);
	listOfAttributes.add(attribute5);
	//TODO: Same problem like with userExtSources, what about null between attributes? Not Supported Now!
	//listOfAttributes.add(null);
	listOfAttributes.add(attribute6);
	RichMember richMember3 = new RichMember(null, member, null, listOfAttributes, listOfAttributes);
	List<PerunBean> richMember1InList = AuditParser.parseLog(richMember1.serializeToString());
	//TODO: What about null pointers between userExtSources? Not Supported yet
	//List<PerunBean> richMember2InList = AuditParser.parseLog(richMember2.serializeToString());
	List<PerunBean> richMember3InList = AuditParser.parseLog(richMember3.serializeToString());
	assertEquals(richMember1.toString(), ((RichMember) richMember1InList.get(0)).toString());
	assertEquals(richMember1.isSponsored(), ((RichMember) richMember1InList.get(0)).isSponsored());
	//assertEquals(richMember2, ((RichMember) richMember2InList.get(0)));
	assertEquals(richMember3.toString(), ((RichMember) richMember3InList.get(0)).toString());
	assertEquals(richMember3.isSponsored(), ((RichMember) richMember3InList.get(0)).isSponsored());
	assertEquals(richMember1.getUser(), ((RichMember) richMember1InList.get(0)).getUser());
	assertEquals(richMember1.getUserExtSources(), ((RichMember) richMember1InList.get(0)).getUserExtSources());
	//FOR RICHUSER
	RichUser richUser1 = new RichUser(user, null, null);
	richUser1.setUuid(UUID.randomUUID());
	RichUser richUser2 = new RichUser(user, null, listOfAttributes);
	List<PerunBean> richUserInList = AuditParser.parseLog(richUser.serializeToString());
	List<PerunBean> richUser1InList = AuditParser.parseLog(richUser1.serializeToString());
	List<PerunBean> richUser2InList = AuditParser.parseLog(richUser2.serializeToString());
	assertEquals(richUser.toString(), ((RichUser) richUserInList.get(0)).toString());
	assertEquals(richUser1.toString(), ((RichUser) richUser1InList.get(0)).toString());
	assertEquals(richUser1.getUuid(), ((RichUser) richUser1InList.get(0)).getUuid());
	assertEquals(richUser2.toString(), ((RichUser) richUser2InList.get(0)).toString());
	//FOR RICHGROUP
	RichGroup richGroup1 = new RichGroup(group, null);
	richGroup1.setUuid(UUID.randomUUID());
	List<PerunBean> richGroupInList = AuditParser.parseLog(richGroup.serializeToString());
	List<PerunBean> richGroup1InList = AuditParser.parseLog(richGroup1.serializeToString());
	assertEquals(richGroup.toString(), ((RichGroup) richGroupInList.get(0)).toString());
	assertEquals(richGroup1.toString(), ((RichGroup) richGroup1InList.get(0)).toString());
	assertEquals(richGroup1.getUuid(), ((RichGroup) richGroup1InList.get(0)).getUuid());
	//FOR RICHFACILITY
	RichFacility richFacility1 = new RichFacility(facility, null);
	List<Owner> owners = new ArrayList<Owner>();
	owners.add(owner);
	owners.add(owner1);
	owners.add(owner2);
	RichFacility richFacility2 = new RichFacility(facility, owners);
	List<PerunBean> richFacility1InList = AuditParser.parseLog(richFacility1.serializeToString());
	List<PerunBean> richFacility2InList = AuditParser.parseLog(richFacility2.serializeToString());
	assertEquals(richFacility1.toString(), ((RichFacility) richFacility1InList.get(0)).toString());
	assertEquals(richFacility2.toString(), ((RichFacility) richFacility2InList.get(0)).toString());
	//FOR RICHRESOURCE
	RichResource richResource = new RichResource(resource);
	richResource.setFacility(null);
	richResource.setVo(null);
	richResource.addResourceTag(resourceTag1);
	richResource.setUuid(UUID.randomUUID());
	List<PerunBean> richResourceInList = AuditParser.parseLog(richResource.serializeToString());
	assertEquals(richResource.toString(), ((RichResource) richResourceInList.get(0)).toString());
	assertEquals(richResource.getFacility(), ((RichResource) richResourceInList.get(0)).getFacility());
	assertEquals(richResource.getUuid(), ((RichResource) richResourceInList.get(0)).getUuid());
	//FOR RICHDESTINATION
	RichDestination richDestination = new RichDestination(destination, null, null);
	List<PerunBean> richDestinationInList = AuditParser.parseLog(richDestination.serializeToString());
	assertEquals(richDestination.toString(), ((RichDestination) richDestinationInList.get(0)).toString());
	assertEquals(richDestination.getFacility(), ((RichDestination) richDestinationInList.get(0)).getFacility());
	//FOR AUTHORSHIP
	Authorship authorship1 = new Authorship();
	authorship1.setId(1);
	authorship1.setPublicationId(3);
	authorship1.setUserId(18);
	authorship1.setCreatedBy(textMismatch);
	authorship1.setCreatedDate(new Date());
	authorship1.setCreatedByUid(10);
	Authorship authorship2 = new Authorship();
	authorship2.setId(1);
	authorship2.setPublicationId(3);
	authorship2.setUserId(18);
	authorship2.setCreatedBy(null);
	authorship2.setCreatedDate(null);
	authorship2.setCreatedByUid(0);
	List<PerunBean> authorship1InList = AuditParser.parseLog(authorship1.serializeToString());
	List<PerunBean> authorship2InList = AuditParser.parseLog(authorship2.serializeToString());
	assertEquals(authorship1.toString(), ((Authorship) authorship1InList.get(0)).toString());
	assertEquals(authorship2.toString(), ((Authorship) authorship2InList.get(0)).toString());
}