Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*******************************************************************************
* Copyright (C) 2021, 1C-Soft LLC and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Aleksandr Kapralov - initial API and implementation
*******************************************************************************/
package com.e1c.v8codestyle.internal.md.itests;

import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EStructuralFeature;

import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.ReturnValuesReuse;
import com.e1c.g5.v8.dt.testing.check.CheckTestBase;

/**
* @author Aleksandr Kapralov
*
*/
public abstract class CheckMd
extends CheckTestBase
{

protected void updateCommonModule(IDtProject dtProject, String fqn, Map<EStructuralFeature, Boolean> types,
ReturnValuesReuse returnValueReuse, String newFqn)
{
IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change type")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject object = transaction.getTopObjectByFqn(fqn);

for (Entry<EStructuralFeature, Boolean> entry : types.entrySet())
{
object.eSet(entry.getKey(), entry.getValue());
}

if (!(object instanceof CommonModule))
{
return null;
}

CommonModule module = (CommonModule)object;

if (returnValueReuse != null)
{
module.setReturnValuesReuse(returnValueReuse);
}

if (newFqn != null)
{
String[] fqnArray = newFqn.split("[.]");
if (fqnArray.length == 2)
{
module.setName(fqnArray[1]);
transaction.updateTopObjectFqn(object, newFqn);
}
}

return null;
}
});
waitForDD(dtProject);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,17 @@
* 1C-Soft LLC - initial API and implementation
* Aleksandr Kapralov - issue #14
*******************************************************************************/
package com.e1c.v8codestyle.md.itests;
package com.e1c.v8codestyle.md.check.itests;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.junit.Test;

import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.ReturnValuesReuse;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.g5.v8.dt.testing.check.CheckTestBase;
import com.e1c.v8codestyle.internal.md.itests.CheckMd;
import com.e1c.v8codestyle.md.check.CommonModuleNameClientServer;
import com.e1c.v8codestyle.md.check.CommonModuleType;

Expand All @@ -42,7 +32,7 @@
*
*/
public class CommonModuleNameClientServerTest
extends CheckTestBase
extends CheckMd
{

private static final String CHECK_ID = "common-module-name-client-server";
Expand Down Expand Up @@ -127,45 +117,4 @@ public void testCommonModuleNameClientServerReturnValueReuseCorrect() throws Exc
assertNull(marker);
}

private void updateCommonModule(IDtProject dtProject, String fqn, Map<EStructuralFeature, Boolean> types,
ReturnValuesReuse returnValueReuse, String newFqn)
{
IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change type")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject object = transaction.getTopObjectByFqn(fqn);

for (Entry<EStructuralFeature, Boolean> entry : types.entrySet())
{
object.eSet(entry.getKey(), entry.getValue());
}

if (!(object instanceof CommonModule))
{
return null;
}

CommonModule module = (CommonModule)object;

module.setReturnValuesReuse(returnValueReuse);

if (newFqn != null)
{
String[] fqnArray = newFqn.split("[.]");
if (fqnArray.length == 2)
{
module.setName(fqnArray[1]);
transaction.updateTopObjectFqn(object, newFqn);
}
}

return null;
}
});
waitForDD(dtProject);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,17 @@
* 1C-Soft LLC - initial API and implementation
* Aleksandr Kapralov - issue #14
*******************************************************************************/
package com.e1c.v8codestyle.md.itests;
package com.e1c.v8codestyle.md.check.itests;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.junit.Test;

import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.ReturnValuesReuse;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.g5.v8.dt.testing.check.CheckTestBase;
import com.e1c.v8codestyle.internal.md.itests.CheckMd;
import com.e1c.v8codestyle.md.check.CommonModuleNameClient;
import com.e1c.v8codestyle.md.check.CommonModuleType;

Expand All @@ -42,7 +32,7 @@
*
*/
public class CommonModuleNameClientTest
extends CheckTestBase
extends CheckMd
{

private static final String CHECK_ID = "common-module-name-client";
Expand Down Expand Up @@ -127,45 +117,4 @@ public void testCommonModuleNameClientReturnValueReuseCorrect() throws Exception
assertNull(marker);
}

private void updateCommonModule(IDtProject dtProject, String fqn, Map<EStructuralFeature, Boolean> types,
ReturnValuesReuse returnValueReuse, String newFqn)
{
IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change type")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject object = transaction.getTopObjectByFqn(fqn);

for (Entry<EStructuralFeature, Boolean> entry : types.entrySet())
{
object.eSet(entry.getKey(), entry.getValue());
}

if (!(object instanceof CommonModule))
{
return null;
}

CommonModule module = (CommonModule)object;

module.setReturnValuesReuse(returnValueReuse);

if (newFqn != null)
{
String[] fqnArray = newFqn.split("[.]");
if (fqnArray.length == 2)
{
module.setName(fqnArray[1]);
transaction.updateTopObjectFqn(object, newFqn);
}
}

return null;
}
});
waitForDD(dtProject);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,17 @@
* 1C-Soft LLC - initial API and implementation
* Aleksandr Kapralov - issue #14
*******************************************************************************/
package com.e1c.v8codestyle.md.itests;
package com.e1c.v8codestyle.md.check.itests;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.junit.Test;

import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.ReturnValuesReuse;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.g5.v8.dt.testing.check.CheckTestBase;
import com.e1c.v8codestyle.internal.md.itests.CheckMd;
import com.e1c.v8codestyle.md.check.CommonModuleNameGlobal;
import com.e1c.v8codestyle.md.check.CommonModuleType;

Expand All @@ -42,7 +32,7 @@
*
*/
public class CommonModuleNameGlobalTest
extends CheckTestBase
extends CheckMd
{

private static final String CHECK_ID = "common-module-name-global";
Expand Down Expand Up @@ -203,45 +193,4 @@ public void testCommonModuleNameServerGlobalReturnValueReuseCorrect() throws Exc
assertNull(marker);
}

private void updateCommonModule(IDtProject dtProject, String fqn, Map<EStructuralFeature, Boolean> types,
ReturnValuesReuse returnValueReuse, String newFqn)
{
IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change type")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject object = transaction.getTopObjectByFqn(fqn);

for (Entry<EStructuralFeature, Boolean> entry : types.entrySet())
{
object.eSet(entry.getKey(), entry.getValue());
}

if (!(object instanceof CommonModule))
{
return null;
}

CommonModule module = (CommonModule)object;

module.setReturnValuesReuse(returnValueReuse);

if (newFqn != null)
{
String[] fqnArray = newFqn.split("[.]");
if (fqnArray.length == 2)
{
module.setName(fqnArray[1]);
transaction.updateTopObjectFqn(object, newFqn);
}
}

return null;
}
});
waitForDD(dtProject);
}

}
Loading